<?php
namespace App\Controllers;
SESSION_START();
use \Core\View;
use \Core\Inputs;
use \Core\Userlog;
use \Core\Form;
use App\Models\Homem;
use App\Email\Emails;
class Admissions extends \Core\Controller
{
    public static function addmissionapplicationfeeonluprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {


            $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_admissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id ORDER BY a.id DESC ");

            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Application Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/addmissionapplicationfeerecieptprint', 'id', '');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-2"></div>
                        </div>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
            if($_SESSION["org_id"] == '3')
            {
                echo '<script>
                $("#no").val("HCET");
                document.getElementById("no").readOnly = true;
                $("#year").val("'.date('Y').'");
                $("#amount").val("0");
                document.getElementById("amount").readOnly = true;
                </script>';
            }
        }
    }
    public static function provisionaladdmissionfeeonluprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $blood = Homem::getdata("SELECT a.*, b.code as course FROM stdnt_provisionaladmissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id  WHERE a.receipt_no!='' ORDER BY a.id DESC ");
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Mobile Number', 'Reciept Number', 'Amount', 'Date'], ['name', 'course', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/provisionalfeerecieptprint', 'id', '');
            
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                
                    <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">
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3"></div>
                        </div>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            function getapplicationdetails()
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/getapplicationdetails",
                    type: "post",
                    data: {no:no},
                    success: function(d) {
                        {
                            const a = JSON.parse(d);
                            document.getElementById("sname").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("course").value = a[0]["fk_course_id"];
                            document.getElementById("department").value = a[0]["fk_dept_id"];
                            getadmissionyear();
                        }
                    }
                });
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    public static function discontinuedstudents()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 8)
        {
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $table = '';
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Admissions/savediscontinuedstudents" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Fee Payment Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly required>                                         
                                                    </div>
                                                </div>
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>                                         
                                                    </div>
                                                </div>
                                                
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="email" id="email" class="form-control" placeholder="Student Email" readonly required>                                         
                                                    </div>
                                                </div> 
                                                
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <select name="dis" id="dis" class="form-control" >
                                                            <option value="">Discontinued</option>
                                                            <option value="1">Yes</option>
                                                            <option value="">No</option>
                                                        </select>
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                    <input type="hidden" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Fee Paid Date"> 
                                                        <select name="tc" id="tc" class="form-control" >
                                                            <option value="">TC Issued</option>
                                                            <option value="1">Yes</option>
                                                            <option value="">No</option>
                                                        </select>                                   
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group"> 
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="user id" required>
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                $(document).ready(function(){
                    var div = document.createElement("div");
                    div.id = "addcoplayerinner1";
                    document.getElementsByTagName("body")[0].appendChild(div);
                    $("#addcoplayerinner1").load("/Accounts/addcoplayerinner");
                });
                // $(document).ready(function(){
                //     var div = document.createElement("div");
                //     div.id = "foundcoplayerinner1";
                //     document.getElementsByTagName("body")[0].appendChild(div);
                //     $("#foundcoplayerinner1").load("/Accounts/foundcoplayerinner");
                // });
                function updatecontactdetails()
                {
                    $("#addcoplayerinner").modal("show");
                }
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusernamemobileemail",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            const a = JSON.parse(d);
                            document.getElementById("name").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("email").value = a[0]["email"];
                            if(a[0]["id"] != "")
                            {
                                $("#modifylink").show();
                            }
                            getuserid();
                            setTimeout(function(){ $("#id").val(a[0]["id"]); }, 500);
                            $("#id").val(a[0]["id"]);
                            $("#sno").val(a[0]["no"]);
                            $("#sname").val(a[0]["name"]);
                            $("#gender").val(a[0]["gender"]);
                            $("#dob").val(a[0]["dob"]);
                            $("#smobile").val(a[0]["mobile"]);
                            $("#semail").val(a[0]["email"]);
                            $("#fname").val(a[0]["fname"]);
                            $("#fmobile").val(a[0]["fmobile"]);
                        }
                    });
                }

                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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>';
                }
            }
            if(isset($_GET['no']))
            {
                echo '
                    <script>
                        $("#no").val("'.$_GET['no'].'");
                        getusername();
                    </script>';
            }
        }
    }
    public static function savediscontinuedstudents()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `id`='$_POST[sid]' AND (`ano`='$_POST[no]' OR `no`='$_POST[no]')");
            {
                if($_POST['edit_id'] == '')
                {
                    if(sizeof($data) == 1)
                    {
                        Homem::insert("UPDATE `user_master` SET `discontinued`='$_POST[dis]', `tc_given`='$_POST[tc]', `add_date`='$date', `add_by`='$_SESSION[user_id]' WHERE `id`='$_POST[sid]' AND `no`='$_POST[no]'");
                        echo '<script>window.location = "/Admissions/discontinuedstudents?status=1";</script>';
                    }
                    else
                    {
                        echo '<script>window.location = "/Admissions/discontinuedstudents?status=2";</script>';
                    }
                }
            }
        }
    }
    /*Addtional Fee Collection --  started*/
    public static function additionalfeecollection()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 8)
        {
            $feetype = Homem::getdata("SELECT * FROM `additional_add_fee_type`");
            $a = '<div class="row">';
            for($i=0; $i<sizeof($feetype); $i++)
            {
                $a .= '
                <div class="col-md-6">
                    <div class="form-group">
                        <input name="feetype['.$feetype[$i]['id'].']" id="feetype['.$feetype[$i]['id'].']" class="form-control" placeholder="'.$feetype[$i]['name'].'" >
                    </div>
                </div>';      
            }
            $a .= '</div>';
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $table = '';
            {
                $date = date('Y-m-d');
                // $blood = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE (`entry_date`='$date' OR `edit_date`='$date') AND (`entry_id`='$_SESSION[user_id]' OR `edit_id`='$_SESSION[user_id]') AND `fk_org_id`='$_SESSION[org_id]'");
                $blood = Homem::getdata("SELECT sa.id as rid, sa.*, sm.* FROM stdnt_additional_addfee sa JOIN stdnt_admissionfee sm ON sm.id=sa.sid WHERE sa.fk_user_id='$_SESSION[user_id]' AND sa.paid_date='$date' AND sa.status='1'");
                $table = Form::dbtableprint($blood, ['Admission Number', 'Hallticket Number', 'Name', 'Mobile', 'Paid Amount'], ['sid', 'sno', 'name', 'mobile', 'total'], '/Admissions/additionalfeeprint', 'rid', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Admissions/saveadditionalfeecolectnew" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Additional Fee Payment Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly required>                                         
                                                    </div>
                                                </div>
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>                                         
                                                    </div>
                                                </div>
                                                
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="email" id="email" class="form-control" placeholder="Student Email" readonly required>                                         
                                                    </div>
                                                </div> 
                                                
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control" required>
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feemode" id="feemode" class="form-control" required>
                                                            <option value="">Select Mode of Payment</option>
                                                            '.$feemode.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            '.$a.'
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="recieptno" id="recieptno" class="form-control" placeholder="Reciept Number">
                                                        <input type="number" name="total" id="total" class="form-control" placeholder="Total Amount Paid" required>
                                                        
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                    <input type="hidden" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Fee Paid Date"> 
                                                    <input type="text" name="remarks" id="remarks" class="form-control" placeholder="Remarks">                                   
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row" id="modifylink" style="display:none;">
                                                    <div class="col-lg-12">
                                                        <div class="float-lg-right"><a href="javascript:void(0);" onclick="updatecontactdetails()">Change Contact Information</a></div> 
                                                    </div>
                                            </div>
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group"> 
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="user id" required>
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Admissions/getapplicationdetails",
                        type: "post",
                        data: {no:no},
                        success: function(d) {
                            {
                                const a = JSON.parse(d);
                                document.getElementById("name").value = a[0]["name"];
                                document.getElementById("mobile").value = a[0]["mobile"];
                            }
                        }
                    });
                }
            </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>';
                }
            }
            if(isset($_GET['no']))
            {
                echo '
                    <script>
                        $("#no").val("'.$_GET['no'].'");
                        getusername();
                    </script>';
            }
        }
    }
    public static function saveadditionalfeecolectnew()
    {
        $date = date('Y-m-d');
        $i = 1;
        $total = 0;
        foreach ($_POST['feetype'] as $value) {
                if($value=="")
                {
                    $value = 0;
                }
                  $a[$i] = $value;
                  $i++;
                  $total = $total+(int)$value;
            }
            $b = json_encode($a);
        if($total == $_POST['total'] && $total>0)
        {
            $data = Homem::getdata("SELECT * FROM `stdnt_admissionfee` WHERE `fk_stdntenquiry_id`='$_POST[no]' AND `receipt_no`='$_POST[no]'");
            if(sizeof($data) == 1)
            {
                $_POST["sid"] = $data[0]["id"];
                $query="INSERT INTO `stdnt_additional_addfee` (`id`, `sid`, `sno`, `year`, `mode`, `fees`, `total`, `remarks`, `fk_user_id`, `paid_date`, `status`) VALUES 
                (NULL, '$_POST[sid]', '$_POST[no]', '$_POST[year]', '$_POST[feemode]', '$b', '$_POST[total]', '$_POST[remarks]', '$_SESSION[user_id]', '$date', '1')";
                Homem::insert($query);
                echo '<script>window.location = "/Admissions/additionalfeecollection?status=1";</script>';
            }
            else
             {
                 echo '<script>window.location = "/Admissions/additionalfeecollection?status=0";</script>';
             } 
             
         }
         else
         {
             echo '<script>window.location = "/Admissions/additionalfeecollection?status=0";</script>';
         }
    }
    public static function additionalfeeprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT a.*, fm.name as feemode, u.name as opname FROM (SELECT sn.id, sn.sno, sn.total, sn.paid_date, sn.year, sn.mode, sn.fees, sn.fk_user_id, um.name, um.fk_course_id, um.fk_dept_id FROM stdnt_additional_addfee sn JOIN stdnt_admissionfee um ON sn.sid=um.id WHERE sn.id='$_GET[editid]') a JOIN fee_mode fm ON a.mode=fm.id JOIN user_master u ON a.fk_user_id=u.id");
                $a ='';
                $d = json_decode($data[0]['fees'], true);
                for($i=0; $i<sizeof($d); $i++)
                {
                    $j = $i+1;
                    if($d[$j] > 0)
                    {
                        $a .= '<tr style="text-align: center;"><td width="70%" style="border: thin solid black">'.static::additionalfeetype($j).'</td><td width="70%" style="border: thin solid black">'.number_format($d[$j], 2).'</td></tr>';        
                    }
                }
                $a .= '<tr style="text-align: center;"><td width="70%" style="border: thin solid black"><b>Total Amount</b></td><td width="70%" style="border: thin solid black">'.number_format($data[0]['total'], 2).'</td></tr>';
                
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::recieptheader().'
                                                        <tr>
                                                            <td><span style="margin-left: 10px;">Reciept Number: '.$data[0]['id'].'</span></td>
                                                            <td style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['paid_date']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Name : &nbsp; </b>'.$data[0]['name'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Department :  &nbsp; </b>'.static::course($data[0]['fk_course_id']).'-'.static::dept($data[0]['fk_dept_id']).'</span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>HT No. / PIN : &nbsp; </b>'.$data[0]['sno'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Year :  &nbsp; </b>'.static::nyear($data[0]['year']).'</span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                <b>Fee Particulars</b>
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                <b>Amount (Rs.)</b>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                    <tbody>
                                                            '.$a.'
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="2">
                                                                <span style="margin-left: 10px;"><b>Amount in words: </b>'.static::numtotext($data[0]['total']).'</span>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <span style="margin-right: 10px;">
                                                                    <b>Mode of payment: </b> '.$data[0]['feemode'].'
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>Office Inchage / Accountant </b> <br>('.$data[0]['opname'].')
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    private static function additionalfeetype($id)
    {
        if($_SESSION['org_id'] == 1)
        {
            if($id == 1)
            {
                return 'PCB Designing Course';
            }
            
        }
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1)
            {
                return 'Processing Fee';
            }
            if($id == 2)
            {
                return 'Study Material & Stationary Fee';
            }
            if($id == 3)
            {
                return 'Bus Fee';
            }
            if($id == 4)
            {
                return 'University Common Services Fee';
            }
            if($id == 5)
            {
                return 'RECORD FEE';
            }
            if($id == 6)
            {
                return 'ID CARD FEE';
            }
        }
        if($_SESSION['org_id'] == 4)
        {
            if($id == 1)
            {
                return 'Web Development';
            }
        }
        if($_SESSION['org_id'] == 5)
        {
            if($id == 1)
            {
                return 'Processing Fee';
            }
            if($id == 2)
            {
                return 'Study Material & Stationary Fee';
            }
            if($id == 3)
            {
                return 'Bus Fee';
            }
            if($id == 4)
            {
                return 'University Common Services Fee';
            }
            if($id == 5)
            {
                return 'RECORD FEE';
            }
            if($id == 6)
            {
                return 'ID CARD FEE';
            }
        }
    }
    private static function additionalfeefeedivisonforreports($data)
    {
        $data = json_decode($data, true);
        for($i=0; $i<sizeof($data); $i++)
        {
            $subdata = json_decode($data[$i]['fees'], true);
            for($j=1; $j<=sizeof($subdata); $j++)
            {
                $data[$i][$j] = $subdata[$j];
            }
        }
        return json_encode($data);
        
    }
    public static function additionalfeefeedivisonforreportsbysinlefeeid($data, $type)
    {
        $data = json_decode($data, true);
        $type1 = $type;
        $type = 'type'.$type;
        for($i=0; $i<sizeof($data); $i++)
        {
            if(isset($data[$i][$type1]))
            {
                $data[$i][$type] = $data[$i][$type1];
            }
            else
            {
                $data[$i][$type] = 0;
            }
        }
        return json_encode($data);
    }
    public static function additionalfeecollectionsummary()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 8)
        {
            $month = Inputs::optionsdb(Homem::getdata("SELECT * FROM `month`"), 'month_id', 'month_name');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `additional_add_fee_type`"), 'id', 'name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            // $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            // $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $table = '';
            $a ='';
            {
                $date = date('Y-m-d');
                if(isset($_POST['course']))
                {
                    $_POST['month'] = date('m');
                    $_POST['syear'] = date('Y');
                $blood = Homem::getdata("SELECT sn.id, sn.paid_date, sn.fk_user_id, sn.mode, sn.year, sn.fees, sn.total, um.name, um.fk_stdntenquiry_id, um.fk_stdntenquiry_id as no, u.name as username FROM stdnt_additional_addfee sn JOIN stdnt_admissionfee um ON um.id=sn.sid JOIN user_master u ON u.id=sn.fk_user_id");//(sn.edate='$date') AND 
                // $blood = Homem::getdata("SELECT sn.id as nid, sn.*, um.name, um.no, u.name as username FROM stdnt_additional_addfee sn JOIN stdnt_admissionfee um ON um.id=sn.sid JOIN user_master u ON u.id=sn.fk_user_id WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]'  AND sn.year='$_POST[year]' ORDER BY um.no ASC");//(sn.edate='$date') AND 
                //additionalfeecollectionsummary
                $blood = static::additionalfeefeedivisonforreports(json_encode($blood));
                $type = $_POST['feetype'];
                $typename = static::additionalfeetype($type);
                $data = json_decode(static::additionalfeefeedivisonforreportsbysinlefeeid($blood, $type), true);
                $a = '';
                $type = 'type'.$_POST['feetype'];
                $k=0;
                for($i=0; $i<sizeof($data); $i++)
                {
                    if($data[$i][$type] > 0)
                    {
                        $k++;
                        $a .= '<tr><td>'.$k.'</td><td>'.$data[$i]['fk_stdntenquiry_id'].'</td><td>'.$data[$i]['name'].'</td><td>'.$data[$i][$type].'</td><td>'.$data[$i]['username'].'</td><td>'.static::datem($data[$i]['paid_date']).'</td></tr>';
                    }
                }
                // echo json_encode($blood);
                // $table = Form::dbtableprint($blood, ['Reciept No', 'Admission Number', 'Hallticket Number', 'Name', 'Paid Amount', 'Paid to', 'remarks'], ['nid', 'ano', 'no', 'name', 'total', 'username', 'remarks'], '', '', '');
            }
            $a = '<div class="table-responsive">
                    <table class="table table-responsive-sm">
                        <thead>
                            <tr><th>S. No.</th><th>Pin</th><th>Name</th><th>Amount</th><th>Paid to</th><th>Paid Date</th></tr>
                        </thead>
                        <tbody>
                            '.$a.'
                        </tbody>
                    </table>
                </div>';
                }

            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"> 
                            </div>
                            <div class="col-lg-8">
                                <form action="/Admissions/additionalfeecollectionsummary" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Additional Fee Collection Summary</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="year" id="year" class="form-control" required>
                                                                <option value="">Select Year of Course</option>
                                                                <option value="1">First Year</option>
                                                                <option value="2">Second Year</option>
                                                                <option value="3">Third Year</option>
                                                                <option value="4">Fourth Year</option>
                                                                <option value="ALL">All Years</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <div class="form-group">                                            
                                                            <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                                <option value="">Select Fee Type</option>
                                                                '.$feetype.'
                                                            </select>											
                                                        </div>
                                                    </div>                              
                                                    <div class="col-md-4">
                                                        <div class="form-group">
                                                            
                                                        </div>
                                                    </div>                                       
                                                </div>
                                                
                                            <div class="row">
                                                <div class="col-md-4">
                                                    <div class="form-group">
                                                    </div>
                                                </div> 
                                                <div class="col-md-4">
                                                    <div class="form-group">                                            
                                                       												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-4">
                                                    <div class="form-group">
                                                        
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-2">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$a.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                $(document).ready(function(){
                    var div = document.createElement("div");
                    div.id = "addcoplayerinner1";
                    document.getElementsByTagName("body")[0].appendChild(div);
                    $("#addcoplayerinner1").load("/Accounts/addcoplayerinner");
                });
                // $(document).ready(function(){
                //     var div = document.createElement("div");
                //     div.id = "foundcoplayerinner1";
                //     document.getElementsByTagName("body")[0].appendChild(div);
                //     $("#foundcoplayerinner1").load("/Accounts/foundcoplayerinner");
                // });
                function updatecontactdetails()
                {
                    $("#addcoplayerinner").modal("show");
                }
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusernamemobileemail",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            const a = JSON.parse(d);
                            document.getElementById("name").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("email").value = a[0]["email"];
                            if(a[0]["id"] != "")
                            {
                                $("#modifylink").show();
                            }
                            getuserid();
                            setTimeout(function(){ $("#id").val(a[0]["id"]); }, 500);
                            $("#id").val(a[0]["id"]);
                            $("#sno").val(a[0]["no"]);
                            $("#sname").val(a[0]["name"]);
                            $("#gender").val(a[0]["gender"]);
                            $("#dob").val(a[0]["dob"]);
                            $("#smobile").val(a[0]["mobile"]);
                            $("#semail").val(a[0]["email"]);
                            $("#fname").val(a[0]["fname"]);
                            $("#fmobile").val(a[0]["fmobile"]);
                        }
                    });
                }
                function getdueamount()
                {
                    var no = $("#no").val();
                    var year = $("#year").val();
                    var feetype = $("#feetype").val();
                    $.ajax({
                        url: "/Accounts/getdueamount",
                        type: "post",
                        data: {no: no, year: year, feetype: feetype},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("dueamount").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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>';
                }
            }
            if(isset($_GET['no']))
            {
                echo '
                    <script>
                        $("#no").val("'.$_GET['no'].'");
                        getusername();
                    </script>';
            }
        }
    }
    /*Addtional Fee Collection --  Ended*/
    
    public static function addmissionenquiry()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master` WHERE `status`='1'"), 'id', 'name');
            $blood = Homem::getdata("SELECT a.*, b.code as course FROM stdnt_admissionenquiry a JOIN degree_name_master b ON a.course=b.id WHERE a.fk_user_id=$_SESSION[user_id] ORDER BY a.id DESC ");
            
            if($_SESSION['user_role'] == 6)
            {
                $blood = Homem::getdata("SELECT a.*, b.code as course FROM stdnt_admissionenquiry a JOIN degree_name_master b ON a.course=b.id ORDER BY a.id DESC ");
            }
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Mobile'], ['name', 'course', 'mobile'], '', '', '');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/saveaddmissionenquiry" method="POST">
                
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left">ADMISSION ENQUIRY</h4>
                                                <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">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name as per SSC" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="swmobile" id="swmobile" class="form-control" placeholder="Student WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pname" id="pname" class="form-control" placeholder="Parent Name as per SSC">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pmobile" id="pmobile" class="form-control" placeholder="Parent Mobile Number">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pwmobile" id="pwmobile" class="form-control" placeholder="Parent WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <input name="city" id="city" class="form-control" placeholder="City">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="school" id="school" class="form-control" placeholder="School / College Name" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="marks" id="marks" class="form-control" placeholder="Marks" required>
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>   
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="year" id="year" class="form-control" placeholder="Admission Year" readonly>
                                                        </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-2"></div>
                        </div>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
            if($_SESSION["org_id"] == '3')
            {
                echo '<script>
                $("#year").val("'.date('Y').'");
                document.getElementById("year").readOnly = true;
                </script>';
            }
        }
    }
    public static function saveaddmissionenquiry()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            foreach ($_POST as $key => $value){
        		$info[$key]=$value;
        	 }
        	    $info1 = json_encode($info);
            Homem::insert("INSERT INTO `stdnt_admissionenquiry` (`id`, `name`, `mobile`, `course`, `year`, `extra`, `fk_user_id`, `edate`) VALUES (NULL, '$_POST[sname]', '$_POST[mobile]', '$_POST[course]', '$_POST[year]', '$info1', '$_SESSION[user_id]', '$date')");
            echo '<script>window.location = "/Admissions/addmissionenquiry?status=1";</script>';
        }
    }
    public static function cetname()
    {
        $a = "";
        if($_SESSION["org_id"] == 1)
        {
            $a .= '<option value="SSC">SSC</option><option value="INTER">INTER</option><option value="DEGREE">DEGREE</option>';
        }
        if($_SESSION["org_id"] == 3)
        {
            $a .= '<option value="POLYCET">POLYCET</option><option value="EAPCET">EAPCET</option><option value="ECET">ECET</option>';
        }
        if($_SESSION["org_id"] == 4 || $_SESSION["org_id"] == 5)
        {
            $a .= '<option value="ICET">ICET</option>';
        }
        return $a;
    }
    public static function addmissionapplicationfee()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master` WHERE `status`='1'"), 'id', 'name');
            $category = Inputs::optionsdb(Homem::getdata("SELECT * FROM `category`"), 'id', 'name');
            $quota = Inputs::optionsdb(Homem::getdata("SELECT * FROM `squota`"), 'sqid', 'sqname');
            $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_admissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.fk_user_id=$_SESSION[user_id] ORDER BY a.id DESC ");
            
            if($_SESSION['user_role'] == 6)
            {
                $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_admissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id ORDER BY a.id DESC ");
            }
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Application Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/addmissionapplicationfeerecieptprint', 'id', '');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/saveaddmissionapplicationfee" method="POST">
                
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left">APPLICATION FEE FOR ADMISSION</h4>
                                                <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">                                      
                                                            <input type="text" name="no" id="no" class="form-control" placeholder="Application Number" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">
                                                            <input type="text" name="amount" id="amount" class="form-control" placeholder="Amount" required>
                                                        </div></div>
                                                    <div class="col-lg-4">
                                                        <select name="quota" id="quota" class="form-control" required>
                                                            <option value="">Admission Quota</option>
                                                            ';
                                                            echo $quota;
                                                            echo '
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name as per SSC" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="swmobile" id="swmobile" class="form-control" placeholder="Student WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pname" id="pname" class="form-control" placeholder="Parent Name as per SSC">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pmobile" id="pmobile" class="form-control" placeholder="Parent Mobile Number">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pwmobile" id="pwmobile" class="form-control" placeholder="Parent WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <select name="cetname" id="sname" class="form-control" required>
                                                            <option value="">Select Exam Type</option>
                                                            '.static::cetname().'
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="hallticket" id="hallticket" class="form-control" placeholder="Hall Ticket Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="rank" id="rank" class="form-control" placeholder="Rank">
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>   
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="year" id="year" class="form-control" placeholder="Admission Year" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="category" id="category" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Select Category</option>
                                                            ';
                                                            echo $category;
                                                            echo '
                                                            </select>
                                                        </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-2"></div>
                        </div>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
            if($_SESSION["org_id"] == '3')
            {
                echo '<script>
                $("#no").val("HCET");
                document.getElementById("no").readOnly = true;
                $("#year").val("'.date('Y').'");
                $("#amount").val("0");
                document.getElementById("amount").readOnly = true;
                </script>';
            }
        }
    }
    public static function saveaddmissionapplicationfee()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $recieptno = $_POST["no"];
            if($recieptno == "HCET")
            {
                $no = static::generateadmissionnumber($_POST["course"], $_POST["department"], $_POST["year"]);
                $course = $_POST["course"];
                $dept = $_POST["department"];
                if($course == '3'){$f = "HCET";}
                if($course == '1'){$f = "624";}
                if($course == '2'){$f = "2X";}
                if($dept=='1'){$s = "C";}
                if($dept=='2'){$s = "EE";}
                if($dept=='4'){$s = "EC";}
                if($dept=='5'){$s = "CS";}
                if($dept=='8'){$s = "AIM";}
                if($dept=='9'){$s = "AIDS";}
                if($dept=='10'){$s = "CYS";}
                $tmp=$f.$s;
                $tmp .= $no;
                $recieptno = $tmp;
                $_POST["no"] = $recieptno;
                
            }
            foreach ($_POST as $key => $value){
        		$info[$key]=$value;
        	    }
        	    $info1 = json_encode($info);
            Homem::insert("INSERT INTO `stdnt_admissionfee` (`id`, `name`, `mobile`, `fk_course_id`, `fk_dept_id`, `year`, `amount`, `fk_stdntenquiry_id`, `receipt_no`, `fk_user_id`, `regdate`, `status`, `pmobile`, `quota`, `extra`) VALUES 
            (NULL, '$_POST[sname]', '$_POST[mobile]', '$_POST[course]', '$_POST[department]', '$_POST[year]', '$_POST[amount]', '$_POST[no]', '$recieptno', '$_SESSION[user_id]', '$date', '1', '$_POST[pmobile]', '$_POST[quota]', '$info1')");
            echo '<script>window.location = "/Admissions/addmissionapplicationfee?status=1";</script>';
        }
    }
    public static function generateadmissionnumber($course, $dept, $year)
    {
        
        $data = sizeof(Homem::getdata("SELECT * FROM `stdnt_admissionfee` WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `year`='$year'"));
        $data = $data+1;
        return $data;
    }
    public static function addmissionapplicationfeerecieptprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * from `stdnt_admissionfee` WHERE `id`='$_GET[editid]'");
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::recieptheader().'
                                                        <tr>
                                                            <td><span style="margin-left: 10px;">Reciept Number: '.$data[0]['id'].'</span></td>
                                                            <td style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['regdate']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Name : &nbsp; </b>'.$data[0]['name'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Department :  &nbsp; </b>'.static::course($data[0]['fk_course_id']).'-'.static::dept($data[0]['fk_dept_id']).'</span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                <b>Fee Particulars</b>
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                <b>Amount (Rs.)</b>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                 Admission Application Fee
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                '.number_format($data[0]['amount'], 2).'
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="2">
                                                                <span style="margin-left: 10px;"><b>Amount in words: </b>'.static::numtotext($data[0]['amount']).'</span>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <span style="margin-right: 10px;">
                                                                    <b>Mode of payment: </b> Cash
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>Office Inchage / Accountant </b> <br>('.$_SESSION['name'].')
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    public static function updatestudentcontactdetails()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $table = '';
            {
                $date = date('Y-m-d');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Admissions/saveupdatestudentcontactdetails" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">UPDATE STUDENT CONTACT DETAILS</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()" required>                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly required>                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="number" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile" required>                                         
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="email" name="email" id="email" class="form-control" placeholder="Student Email" required>                                         
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="pname" id="pname" class="form-control" placeholder="Parent Name" required>                                         
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="number" name="pmobile" id="pmobile" class="form-control" placeholder="Parent Mobile" required>                                         
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group"> 
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="user id" required>
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                            getuserid();
                        }
                    });
                }
                function getdueamount()
                {
                    var no = $("#no").val();
                    var year = $("#year").val();
                    var feetype = $("#feetype").val();
                    $.ajax({
                        url: "/Accounts/getdueamount",
                        type: "post",
                        data: {no: no, year: year, feetype: feetype},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("dueamount").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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 saveupdatestudentcontactdetails()
    {
        $query = "UPDATE `user_master` SET `fname`='$_POST[pname]', `fmobile`='$_POST[pmobile]', `mobile`='$_POST[mobile]', `email`='$_POST[email]' WHERE `user_role`='3' AND `id`='$_POST[sid]'";
        Homem::insert($query);
        echo '<script>window.location = "/Admissions/updatestudentcontactdetails?status=2";</script>';
    }
    
    public static function attendancereportbetweentwodates()
    {
        if($_SESSION['user_role'] == 8 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 7 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            $a = '';
            if(isset($_POST['date1']))
            {
                $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 WHERE a.course='$_POST[course]' AND a.dept='$_POST[dept]' AND a.year='$_POST[year]'");
                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 = '';
                $a .= '<div class="table-responsive" id="exporttable">';													
                $a .= '<table class="table table-responsive-sm print-this" border="1px">';
                $a .= '<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++)
                {
                    $a .= '<th>'.static::datem($edate[$i]).'</th>';
                }
                $a .= '<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>';
                }
                $a .= '</tbody></table></div>';
            }
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $year = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` WHERE user_role='3' AND fromyear!='' ORDER BY fromyear ASC"), 'fromyear', 'fromyear');
            $fdept = Inputs::optionsdb($data = Homem::getdata("SELECT * FROM (SELECT DISTINCT `fk_dept_id` FROM `user_master` WHERE (`user_role`='2' OR `user_role`='7' OR `user_role`='8') AND `org_id`='$_SESSION[org_id]') a JOIN degree_dept_master ddm ON a.fk_dept_id=ddm.id"), '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-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left"> ATTENDANCE BETWEEN TWO DATES</h4>
                                            </header>
                                            <div class="content-body"> 
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <h6></h6>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="dept" id="dept" class="form-control">
                                                            <option value="">Select Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="year" id="year" class="form-control">
                                                            <option value="">Select Year</option>
                                                            ';
                                                            echo $year;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="date1" id="date1" onfocus="this.type=`date`" onblur="this.type=`text`" placeholder="From Date" class="form-control" required>
            
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="date2" id="date2" onfocus="this.type=`date`" onblur="this.type=`text`" placeholder="To Date" class="form-control" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                        </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-2"></div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$a.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getstdjoinyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course},
                        url: "/Exams/getstdjoinyear",
                        success: function(d){
                            $("#dept").html(d);
                            
                        }
                    });
                }
                function getstudentyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept},
                        url: "/Admissions/getstudentyearforattendance",
                        success: function(d){
                            $("#syear").html(d);
                        }
                    });
                }
                function getstudentdetails()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    var syear = document.getElementById("syear").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept, syear: syear},
                        url: "/Admissions/getstudentdetailsforattendance",
                        success: function(d){
                            $("#students").html(d);
                            // alert(course+dept+regulation+syear);
                        }
                    });
                }
            </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 dailyattendancefirstandlasthourstostudents()
    {
        if($_SESSION['user_role'] == 8 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 7 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $fdept = Inputs::optionsdb($data = Homem::getdata("SELECT * FROM (SELECT DISTINCT `fk_dept_id` FROM `user_master` WHERE (`user_role`='2' OR `user_role`='7' OR `user_role`='8') AND `org_id`='$_SESSION[org_id]') a JOIN degree_dept_master ddm ON a.fk_dept_id=ddm.id"), 'id', 'name');
            $table = '';
            if($_SESSION['user_role'] == 5)
            {
                $blood = Homem::getdata("SELECT dam.*, ddm.code as dname, dnm.code as cname FROM dailyabsentsmsmaster dam JOIN degree_dept_master ddm ON ddm.id=dam.dept JOIN degree_name_master dnm ON dnm.id=dam.course WHERE dam.fk_user_id='$_SESSION[user_id]' ORDER BY dam.id DESC");
            }
            $table = Form::dbtableprint($blood, ['Course', 'Dept', 'Year', 'Total', 'Present', 'Date', 'Faculty Name', 'Room No'], ['cname', 'dname', 'year', 'totalstrength', 'presents', 'edate', 'teacher' ,'roomno'], '', '', '');
            
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/savedailyattendancefirstandlasthours" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left">DAILY ATTENDANCE NOTIFICATION</h4>
                                            </header>
                                            <div class="content-body"> 
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <h6></h6>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" onchange="getstdjoinyear()">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="dept" id="dept" class="form-control" onchange="getstudentyear()">
                                                            <option value="">Select Department</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="syear" id="syear" class="form-control" onchange="getstudentdetails()">
                                                            <option value="">Select Students Joining Year</option>
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="session" id="session" class="form-control" required>
                                                            <option value="">Select Session</option>
                                                            <option value="1">Morning Session</option>
                                                            <option value="2">Afternoon Session</option>
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="hour" id="hour" class="form-control" required>
                                                            <option value="">Select Hour</option>
                                                            <option value="1">First Hour</option>
                                                            <option value="2">Last Hour</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="date" id="date" placeholder="Date of Attendance" onfocus="this.type=`date`" onblur="this.type=`text`" class="form-control">
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="roomno" id="roomno" placeholder="Room No." class="form-control" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="teacher" id="teacher" placeholder="Faculty Name" class="form-control" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="famobile" id="famobile" placeholder="Mobile No." class="form-control" required>
                                                            <input type="hidden" name="intimation" id="intimation" placeholder="Intimation" value="STUDENT" required>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div id="students" class="students">
                                                        </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-2"></div>
                        </div>
                        <div class="row">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$table.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getstdjoinyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course},
                        url: "/Exams/getstdjoinyear",
                        success: function(d){
                            $("#dept").html(d);
                            
                        }
                    });
                }
                function getstudentyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept},
                        url: "/Admissions/getstudentyearforattendance",
                        success: function(d){
                            $("#syear").html(d);
                        }
                    });
                }
                function getstudentdetails()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    var syear = document.getElementById("syear").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept, syear: syear},
                        url: "/Admissions/getstudentdetailsforattendancestudentmobilenumbers",
                        success: function(d){
                            $("#students").html(d);
                            // alert(course+dept+regulation+syear);
                        }
                    });
                }
            </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 dailyattendancefirstandlasthours()
    {
        if($_SESSION['user_role'] == 8 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 7 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $fdept = Inputs::optionsdb($data = Homem::getdata("SELECT * FROM (SELECT DISTINCT `fk_dept_id` FROM `user_master` WHERE (`user_role`='2' OR `user_role`='7' OR `user_role`='8') AND `org_id`='$_SESSION[org_id]') a JOIN degree_dept_master ddm ON a.fk_dept_id=ddm.id"), 'id', 'name');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/savedailyattendancefirstandlasthours" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left">DAILY ATTENDANCE NOTIFICATION</h4>
                                            </header>
                                            <div class="content-body"> 
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <h6></h6>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" onchange="getstdjoinyear()">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="dept" id="dept" class="form-control" onchange="getstudentyear()">
                                                            <option value="">Select Department</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="syear" id="syear" class="form-control" onchange="getstudentdetails()">
                                                            <option value="">Select Students Joining Year</option>
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="session" id="session" class="form-control" required>
                                                            <option value="">Select Session</option>
                                                            <option value="1">Morning Session</option>
                                                            <option value="2">Afternoon Session</option>
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="hour" id="hour" class="form-control" required>
                                                            <option value="">Select Hour</option>
                                                            <option value="1">First Hour</option>
                                                            <option value="2">Last Hour</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="date" id="date" placeholder="Date of Attendance" onfocus="this.type=`date`" onblur="this.type=`text`" class="form-control">
                                                        </div>
                                                        
                                                    </div>

                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="roomno" id="roomno" placeholder="Room No." class="form-control" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="teacher" id="teacher" placeholder="Faculty Name" class="form-control" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">.
                                                        <div class="form-group">  
                                                            <input type="text" name="famobile" id="famobile" placeholder="Mobile No." class="form-control" required>
                                                            <input type="hidden" name="intimation" id="intimation" placeholder="Intimation" value="STUDENT" required>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div id="students" class="students">
                                                        </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-2"></div>
                        </div>
                        <div class="row">
                            <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();
            echo '
            <script>
                function getstdjoinyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course},
                        url: "/Exams/getstdjoinyear",
                        success: function(d){
                            $("#dept").html(d);
                            
                        }
                    });
                }
                function getstudentyear()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept},
                        url: "/Admissions/getstudentyearforattendance",
                        success: function(d){
                            $("#syear").html(d);
                        }
                    });
                }
                function getstudentdetails()
                {
                    var course = document.getElementById("course").value;
                    var dept = document.getElementById("dept").value;
                    var syear = document.getElementById("syear").value;
                    $.ajax({
                        type: "POST",
                        data : {course: course, dept: dept, syear: syear},
                        url: "/Admissions/getstudentdetailsforattendance",
                        success: function(d){
                            $("#students").html(d);
                            // alert(course+dept+regulation+syear);
                        }
                    });
                }
            </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 savedailyattendancefirstandlasthours()
    {
        if($_SESSION['user_role'] == 8 || $_SESSION['user_role'] == 7 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            $work = array();
            $work = $_POST['work'];
            $id = array();
            $id = $_POST['sid'];
            $name = array();
            $name = $_POST['name'];
            $mobile = array();
            $mobile = $_POST['mobile'];
            date_default_timezone_set('Asia/Kolkata');
            $time = date('Y-m-d H:i:s A');
            $present = 0;
            for($i=0; $i<sizeof($_POST['work']); $i++)
            {
                $present = (int) $work[$i] + (int) $present;
            }
            $absent = (int) $_POST['dcount']-(int) $present;
            $query = "INSERT INTO `dailyabsentsmsmaster` (`id`, `course`, `dept`, `year`, `session`, `hour`, `edate`, `etime`, `fk_user_id`, `status`, `verified_by`, `totalstrength`, `absents`, `presents`, `intimation`, `roomno`, `teacher`, `famobile`) VALUES (NULL, '$_POST[course]', '$_POST[dept]', '$_POST[syear]', '$_POST[session]', '$_POST[hour]', '$_POST[date]', '$time', '$_SESSION[user_id]', '1', '', '$_POST[dcount]', '$absent', '$present', '$_POST[intimation]', '$_POST[roomno]', '$_POST[teacher]', '$_POST[famobile]')";
            Homem::insert($query);
            $query = "SELECT * FROM `dailyabsentsmsmaster` WHERE `course`='$_POST[course]' AND `dept`='$_POST[dept]' AND `year`='$_POST[syear]' AND `session`='$_POST[session]' AND `hour`='$_POST[hour]' AND `edate`='$_POST[date]' AND `fk_user_id`='$_SESSION[user_id]' AND `status`='1' AND `totalstrength`='$_POST[dcount]' AND `absents`='$absent' AND `presents`='$present' ORDER BY `id` DESC LIMIT 1";
            $data = Homem::getdata($query);
            $aid = $data[0]['id'];
            for($i=0; $i<sizeof($_POST['work']); $i++)
            {
                $sid = $id[$i];
                $work1 = $work[$i];
                $sname = $name[$i];
                $smobile = $mobile[$i];
                Homem::insert("INSERT INTO `dailyabsentsmsid` (`sid`, `status`, `daily_id`) VALUES ('$sid', '$work1', '$aid')");
                if($work1 == 0 && $smobile !='')
                {
                    // ALTER TABLE `dailyabsentsmsmaster`  ADD `roomno` VARCHAR(15) NOT NULL  AFTER `intimation`,  ADD `teacher` VARCHAR(50) NOT NULL  AFTER `roomno`,  ADD `famobile` VARCHAR(15) NOT NULL  AFTER `teacher`;
                    $ndate = date('Y-m-d');
                    if($_POST["date"] == $ndate)
                    {
                        static::senddailysmstoabsents($sname, $smobile);
                    }
                }
            }
            if($_POST['intimation'] == 'PARENT')
            {
                echo '<script>window.location = "/Admissions/dailyattendancefirstandlasthours?status=1";</script>';
            }
            if($_POST['intimation'] == 'STUDENT')
            {
                echo '<script>window.location = "/Admissions/dailyattendancefirstandlasthourstostudents?status=1";</script>';
            }
        }
    }
    public static function senddailysmstoabsents($name, $mobile)
    {
        $name = static::shortname($name);
        $mobile = $mobile;
        $input = 'Dear Parent, '.$name.' is absent for the class work today. Please inform to the class in-charge regarding the student status- HCHS';
        $url = 'https://api.mylogin.co.in/api/v2/SendSMS?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553&SenderId=HNDGNT&Message='.rawurlencode($input).'&MobileNumbers=91'.$mobile.'&Is_Unicode=false&Is_Flash=false';
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => $url,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        $response = curl_exec($curl);
        curl_close($curl);
        return 1;
    }
    public static function getstudentyearforattendance()
    {
        if(isset($_POST['course']) && isset($_POST['dept']))
        {
            $data = Homem::getdata("SELECT DISTINCT `fromyear` FROM `user_master` WHERE `fk_course_id`='$_POST[course]' AND `fk_dept_id`='$_POST[dept]' AND `org_id`='$_SESSION[org_id]' AND `user_role`='3' AND `fromyear`!='' ORDER BY `fromyear` ASC");
            echo '<option value="">Select Students Joining Year</option>';
            echo Inputs::optionsdb($data, 'fromyear', 'fromyear');
        }
    }
    public static function getstudentdetailsforattendance()
    {
        if(isset($_POST['course']) && isset($_POST['dept']))
        {
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `org_id`='$_SESSION[org_id]' AND `fk_course_id`='$_POST[course]' AND `fk_dept_id`='$_POST[dept]' AND `fromyear`='$_POST[syear]' ORDER BY `no` ASC");
            echo '<h6>List of students in the class: (Number of students: '.sizeof($data).')</h6>';
            echo '<input type="hidden" name="dcount" id="dcount" placeholder="Count" value="'.sizeof($data).'">';
            // echo Form::dbtableed($data, ['Hall Ticket Number', 'Name', 'Gender'], ['no', 'name', 'gender'], '', '', '');
            $data1 = '
            <div class="table-responsive">
                <table class="table table-responsive-sm">
                    <thead>
                        <tr>
                            <th><input type="checkbox" name="allworking" id="allworking" onchange="setallpresent()">Present</th>
                            <th>Hallticket</th>
                            <th>Name</th>
                            <th>Gender</th>
                            <th>Parent Mobile</th>
                        </tr>
                    </thead>
                    <tbody>';
            for($i=0; $i<sizeof($data); $i++)
            {
                $data1 .= '<tr><td><input type="hidden" name="work['.$i.']" id="work['.$i.']" value="0"> <input type="checkbox" name="work['.$i.']" id="work['.$i.']" value="1"></td>';
                if($_SESSION['org_id'] == 1)
                {
                    $data1 .= '<td><input type="hidden" name="rollno['.$i.']" id="rollno['.$i.']" value="'.$data[$i]['roll_no'].'">'.$data[$i]['roll_no'].'</td>';
                }
                $data1 .= '<td><input type="hidden" name="sid['.$i.']" id="sid['.$i.']" value="'.$data[$i]['id'].'">'.$data[$i]['no'].'</td>';
                $data1 .= '<td><input type="hidden" name="name['.$i.']" id="name['.$i.']" value="'.$data[$i]['name'].'">'.$data[$i]['name'].'</td>';
                $data1 .= '<td>'.$data[$i]['gender'].'</td>';
                $data1 .= '<td><input type="hidden" name="mobile['.$i.']" id="mobile['.$i.']" value="'.$data[$i]['fmobile'].'">'.$data[$i]['fmobile'].'</td>';
                $data1 .= '</tr>';
            }
            $data1 .= '</tbody></table>';
            echo $data1;
            echo '
            <script type="text/javascript">  
                $(document).ready(function() {
                });
                function setallpresent()
                {
                    var present = document.getElementById("allworking");
                    if(present.checked == true)
                    {
                        selects();
                    }
                    else
                    {
                        deselects();
                    }
                }
                function selects()
                {  
                    var scount = document.getElementById("dcount");
                    for(var i=0; i<scount.value; i++)
                    { 
                        var a = "work["+i+"]";
                        var ele=document.getElementsByName(a);
                        for(var j=0; j<ele.length; j++)
                        {  
                            if(ele[j].type=="checkbox")  
                            {
                                ele[j].checked=true;
                            }
                        }
                    }
                }   
                function deselects()
                {  
                    var scount = document.getElementById("dcount");
                    for(var i=0; i<scount.value; i++)
                    { 
                        var a = "work["+i+"]";
                        var ele=document.getElementsByName(a);
                        for(var j=0; j<ele.length; j++)
                        {  
                            if(ele[j].type=="checkbox")  
                            {
                                ele[j].checked=false;
                            }
                        }
                    }
                }          
            </script>  
            ';
        }
    }
    public static function getstudentdetailsforattendancestudentmobilenumbers()
    {
        if(isset($_POST['course']) && isset($_POST['dept']))
        {
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `org_id`='$_SESSION[org_id]' AND `fk_course_id`='$_POST[course]' AND `fk_dept_id`='$_POST[dept]' AND `fromyear`='$_POST[syear]' ORDER BY `no` ASC");
            echo '<h6>List of students in the class: (Number of students: '.sizeof($data).')</h6>';
            echo '<input type="hidden" name="dcount" id="dcount" placeholder="Count" value="'.sizeof($data).'">';
            // echo Form::dbtableed($data, ['Hall Ticket Number', 'Name', 'Gender'], ['no', 'name', 'gender'], '', '', '');
            $ectra = '';
            if($_SESSION['org_id'] == 1)
            {
                $ectra = '<th>Roll No.</th>';
            }
            $data1 = '
            <div class="table-responsive">
                <table class="table table-responsive-sm">
                    <thead>
                        <tr>
                            <th><input type="checkbox" name="allworking" id="allworking" onchange="setallpresent()">Present</th>
                            '.$ectra.'
                            <th>Hallticket</th>
                            <th>Name</th>
                            <th>Gender</th>
                            <th>student Mobile</th>
                        </tr>
                    </thead>
                    <tbody>';
            for($i=0; $i<sizeof($data); $i++)
            {
                $data1 .= '<tr><td><input type="hidden" name="work['.$i.']" id="work['.$i.']" value="0"> <input type="checkbox" name="work['.$i.']" id="work['.$i.']" value="1"></td>';
                if($_SESSION['org_id'] == 1)
                {
                    $data1 .= '<td><input type="hidden" name="rollno['.$i.']" id="rollno['.$i.']" value="'.$data[$i]['roll_no'].'">'.$data[$i]['roll_no'].'</td>';
                }
                $data1 .= '<td><input type="hidden" name="sid['.$i.']" id="sid['.$i.']" value="'.$data[$i]['id'].'">'.$data[$i]['no'].'</td>';
                $data1 .= '<td><input type="hidden" name="name['.$i.']" id="name['.$i.']" value="'.$data[$i]['name'].'">'.$data[$i]['name'].'</td>';
                $data1 .= '<td>'.$data[$i]['gender'].'</td>';
                $data1 .= '<td><input type="hidden" name="mobile['.$i.']" id="mobile['.$i.']" value="'.$data[$i]['mobile'].'">'.$data[$i]['mobile'].'</td>';
                $data1 .= '</tr>';
            }
            $data1 .= '</tbody></table>';
            echo $data1;
            echo '
            <script type="text/javascript">  
                $(document).ready(function() {
                });
                function setallpresent()
                {
                    var present = document.getElementById("allworking");
                    if(present.checked == true)
                    {
                        selects();
                    }
                    else
                    {
                        deselects();
                    }
                }
                function selects()
                {  
                    var scount = document.getElementById("dcount");
                    for(var i=0; i<scount.value; i++)
                    { 
                        var a = "work["+i+"]";
                        var ele=document.getElementsByName(a);
                        for(var j=0; j<ele.length; j++)
                        {  
                            if(ele[j].type=="checkbox")  
                            {
                                ele[j].checked=true;
                            }
                        }
                    }
                }   
                function deselects()
                {  
                    var scount = document.getElementById("dcount");
                    for(var i=0; i<scount.value; i++)
                    { 
                        var a = "work["+i+"]";
                        var ele=document.getElementsByName(a);
                        for(var j=0; j<ele.length; j++)
                        {  
                            if(ele[j].type=="checkbox")  
                            {
                                ele[j].checked=false;
                            }
                        }
                    }
                }          
            </script>  
            ';
        }
    }
    // Fee Fixation code start
    public static function cat($id)
    {
        if($id == 1)
        {
            return "OC";   
        }
        if($id == 2)
        {
            return "BC-A";   
        }
        if($id == 3)
        {
            return "BC-B";   
        }
        if($id == 4)
        {
            return "BC-C";   
        }
        if($id == 5)
        {
            return "BC-D";   
        }
        if($id == 6)
        {
            return "BC-E";   
        }
        if($id == 7)
        {
            return "SC";   
        }
        if($id == 8)
        {
            return "ST";   
        }
        
    }
    public static function quotaa($id)
    {
        if($id == "C")
        {
            return "Convener";
        }
        if($id == "M")
        {
            return "Management";
        }
        if($id == "S")
        {
            return "Spot";
        }
    }
    public static function certdata($course)
    {
        $year = date("Y");
        $nyear = $year+1;
        if($course == 1)
        {
            $data[0] = "POLYCET-".$year." Hall Ticket & Rank Card";
            $data[1] = "10<sup>th</sup> Original Marks Memo ";
            $data[2] = "10<sup>th</sup> Class T.C. Original";
            $data[3] = "4 <sup>th</sup> to 10<sup>th</sup> Study Certificates Original";
            $data[4] = "Income certificate – Latest Original";
            $data[5] = "Caste Certificate – Original";
            $data[6] = "EWS Certificate(OC) for ".$year."-".$nyear;
            $data[7] = "Ration Card Xerox";
            $data[8] = "Aadhar Xerox [Student, Mother, Father]";
            $data[9] = "Mother & Student Joint Bank Pass Book 1st page [Xerox] -Student Primary";
            $data[10] = "Passport Photos - 4 ";
            return $data;
        }
        if($course == 2)
        {
            $data[0] = "EAPCET /ECET -".$year." Hall Ticket & Rank Card";
            $data[1] = "10<sup>th</sup> Original Marks Memo ";
            $data[2] = "Diploma / Inter Original Marks Memo ";
            $data[3] = "Diploma / Inter TC - Original";
            $data[4] = "6<sup>th</sup> to 12<sup>th</sup> Study Certificates - Original";
            $data[5] = "Income certificate - Original ";
            $data[6] = "Caste Certificate – Original";
            $data[7] = "EWS Certificate(OC) for ".$year."-".$nyear;
            $data[8] = "Ration Card Xerox";
            $data[9] = "Aadhar Xerox [Student, Mother, Father] ";
            $data[10] = "Mother & Student Joint Pass Book <br/> 1<sup>st</sup> page [Xerox] -Student Primary";
            $data[11] = "Passport Photos - 4 ";
            return $data;
        }
    }
    public static function certmenu()
    {
        $course = $_POST["course"];
        $data = static::certdata($course);
        $a = "";

        $a .= '<div class="table-responsive">
            <table class="table table-responsive-sm">';
        $a .= '<thead>';
        $a .= '<tr>';
        $a .= '<th>S. No.</th>';
        $a .= '<th>List of Certificates</th>';
        $a .= '<th>Original</th>';
        $a .= '<th>Photocopy</th>';
        $a .= '</tr>';
        $a .= '</thead>';
        $a .= '<tbody>';
        for($i=0; $i<sizeof($data); $i++)
        {
            $j=$i+1;
            $a .= '<tr>';
            $a .= '<td>'.$j.'</td>';
            $a .= '<td>'.$data[$i].'</td>';
            $a .= '<td><select name="o['.$i.']" id="o['.$i.']" class="form-control" required>'.static::certoptions().'</select></td>';
            $a .= '<td><select name="d['.$i.']" id="d['.$i.']" class="form-control" required>'.static::certoptions().'</select></td>';
            $a .= '</tr>';
        }
        $a .= '</tbody>';
        $a .= '</table></div>';
        echo $a;
    }
    public static function certoptions()
    {
        $a = '';
        $a .= '<option value="P">Pending</option>';
        $a .= '<option value="Y">Yes</option>';
        $a .= '<option value="N">No</option>';
        return $a;
    }
    public static function certfixing()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master` WHERE `status`='1'"), 'id', 'name');
            $category = Inputs::optionsdb(Homem::getdata("SELECT * FROM `category`"), 'id', 'name');
            $quota = Inputs::optionsdb(Homem::getdata("SELECT * FROM `squota`"), 'sqid', 'sqname');
            $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_admissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.certificates!='' ORDER BY a.id DESC ");
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Application Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/certfixingrecieptprint', 'id', '');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/savecertfixing" 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">
                                                <h4 class="title pull-left">CERTIFICATE SUBMISSION DETAILS ENTRY</h4>
                                                <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">                                      
                                                            <input type="text" name="no" id="no" class="form-control" placeholder="Application Reciept No." onchange="getapplicationdetails()" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <select name="quota" id="quota" class="form-control" required>
                                                            <option value="">Admission Quota</option>
                                                            ';
                                                            echo $quota;
                                                            echo '
                                                        </select>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="category" id="category" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Select Category</option>
                                                            ';
                                                            echo $category;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name" readonly required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="swmobile" id="swmobile" class="form-control" placeholder="Student WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pname" id="pname" class="form-control" placeholder="Parent Name as per SSC">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pmobile" id="pmobile" class="form-control" placeholder="Parent Mobile Number">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pwmobile" id="pwmobile" class="form-control" placeholder="Parent WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <select name="cetname" id="cetname" class="form-control" required>
                                                            <option value="">Select Exam Type</option>
                                                            '.static::cetname().'
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="hallticket" id="hallticket" class="form-control" placeholder="Hall Ticket Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="rank" id="rank" class="form-control" placeholder="Rank">
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>   
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="year" id="year" class="form-control" placeholder="Admission Year" required>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <div id="feedetails"></div>
                                                        </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>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            function getJsonSize(json) 
            {
              var size = 0;
              for (var key in json) {
                if (json.hasOwnProperty(key)) {
                  size++;
                }
              }
              return size;
            }
            function getapplicationdetails()
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/getapplicationdetails",
                    type: "post",
                    data: {no:no},
                    success: function(d) {
                        {
                            const a = JSON.parse(d);
                            document.getElementById("sname").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("course").value = a[0]["fk_course_id"];
                            document.getElementById("department").value = a[0]["fk_dept_id"];
                            
                            if (a[0] && typeof a[0]["category"] !== "undefined") 
                            {
                                document.getElementById("category").value = a[0]["category"];
                            }
                            if (a[0] && typeof a[0]["year"] !== "undefined") 
                            {
                                document.getElementById("year").value = a[0]["year"];
                            }
                            if (a[0] && typeof a[0]["department"] !== "undefined") 
                            {
                                document.getElementById("department").value = a[0]["department"];
                            }
                            if (a[0] && typeof a[0]["course"] !== "undefined") 
                            {
                                document.getElementById("course").value = a[0]["course"];
                            }
                            if (a[0] && typeof a[0]["rank"] !== "undefined") 
                            {
                                document.getElementById("rank").value = a[0]["rank"];
                            }
                            if (a[0] && typeof a[0]["hallticket"] !== "undefined") 
                            {
                                document.getElementById("hallticket").value = a[0]["hallticket"];
                            }
                            if (a[0] && typeof a[0]["cetname"] !== "undefined") 
                            {
                                document.getElementById("cetname").value = a[0]["cetname"];
                            }
                            if (a[0] && typeof a[0]["pwmobile"] !== "undefined") 
                            {
                                document.getElementById("pwmobile").value = a[0]["pwmobile"];
                            }
                            if (a[0] && typeof a[0]["pmobile"] !== "undefined") 
                            {
                                document.getElementById("pmobile").value = a[0]["pmobile"];
                            }
                            if (a[0] && typeof a[0]["pname"] !== "undefined") 
                            {
                                document.getElementById("pname").value = a[0]["pname"];
                            }
                            if (a[0] && typeof a[0]["swmobile"] !== "undefined") 
                            {
                                document.getElementById("swmobile").value = a[0]["swmobile"];
                            }
                            if (a[0] && typeof a[0]["mobile"] !== "undefined") 
                            {
                                document.getElementById("mobile").value = a[0]["mobile"];
                            }
                            if (a[0] && typeof a[0]["sname"] !== "undefined") 
                            {
                                document.getElementById("sname").value = a[0]["sname"];
                            }
                            if (a[0] && typeof a[0]["quota"] !== "undefined") 
                            {
                                document.getElementById("quota").value = a[0]["quota"];
                            }
                            if (a[0] && typeof a[0]["pwmobile"] !== "undefined") 
                            {
                                document.getElementById("pwmobile").value = a[0]["pwmobile"];
                            }
                            getadmissionyear();
                            getfeedetails(a[0]["fk_course_id"]);
                            setTimeout(function() {
                            if (a[0] && typeof a[0]["certificates"] !== "undefined") 
                            {
                                const b = JSON.parse(a[0]["certificates"]);
                                for(j=0; j<getJsonSize(b["o"]); j++)
                                {
                                        var elementId = "o[" + j + "]";
                                        document.getElementById(elementId).value = b["o"][j];
                                }
                                for(j=0; j<getJsonSize(b["d"]); j++)
                                {
                                        var elementId = "d[" + j + "]";
                                        document.getElementById(elementId).value = b["d"][j];
                                }
                            }
                            }, 1000);
                        }
                    }
                });
            }
            function getfeedetails(course)
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/certmenu",
                    type: "post",
                    data: {course:course},
                    success: function(d) {
                        {
                            document.getElementById("feedetails").innerHTML = d;
                            // alert(d);
                        }
                    }
                });
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    public static function savecertfixing()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            foreach ($_POST as $key => $value)
            {
                if($key == "o" || $key == "d")
                {
                    $infoo[$key]=$value;
                }
    	    }
    	    $infoo1 = json_encode($infoo);
    	    Homem::insert("UPDATE `stdnt_admissionfee` SET `certificates`='$infoo1', `fk_cert_id`='$_SESSION[user_id]', `cert_date`='$date' WHERE `receipt_no`='$_POST[no]'");
            echo '<script>window.location = "/Admissions/certfixing?status=1";</script>';
        }
	    
    }
    // certfixingrecieptprint
    private static function certfixingheader()
    {
        if($_SESSION['org_id'] == 1)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>HINDU COLLEGE, GUNTUR</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 2)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 3)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Engineering & Technology</h1>
                    <h5>Approved by AICTE, New Delhi and Affiliated to JNTUK, kakinada & APSBTET</h5>
                    <h5>Amaravathi Road, Guntur-522002</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 4)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 5)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Management</h1>
                    <h5>Amaravathi Road, Guntur-522002, Andhra Pradesh</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 6)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">CERTIFICATE SUBMISSION DETAILS</a>
                </td>
            </tr>
            ';
        }
    }
    public static function certfixingrecieptprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * from `stdnt_admissionfee` WHERE `id`='$_GET[editid]'");
                $extra = json_decode($data[0]["extra"], true);
                $feedetails = json_decode($data[0]["certificates"], true);
                $a = static::certmenufilled($extra["course"], $feedetails);
                // echo count($feedetails["fee"]);
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::certfixingheader().'
                                                    </tbody>
                                                </table>
                                                <table width="100%" style="margin-top:20px;">
                                                    <tbody>
                                                        <tr>
                                                            <td width="60%"><span style="margin-left: 10px;">Provisional Admission Number: <b>'.$data[0]['fk_stdntenquiry_id'].'</b></span></td>
                                                            <td width="40%" style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['regdate']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2"><span style="margin-left: 10px;">Admission Number: ______________</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2"><span style="margin-left: 10px;">Registration / PIN Number: ______________</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Name of the Student</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["sname"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Name of the Parent</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pname"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Course & Department</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::course($extra["course"]).' - '.static::dept($extra["department"]).'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                            <span style="margin-left: 10px;">CET Name</span>
                                                        </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["cetname"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Hallticket No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["hallticket"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Rank</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["rank"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Student Mobile No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["mobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Student WhatsApp No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["swmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Parent Mobile No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Parent WhatsApp No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pwmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Category</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::cat($extra["category"]).'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Admission Type</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::quotaa($extra["quota"]).'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                    </tbody>
                                                </table>
                                                
                                                <table width="90%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="3">
                                                                <span style="margin-left: 50px;"><b>Fee Details: </b></span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                '.$a.'
                                                <table width="100%">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px;">
                                                                    <br><br><br>
                                                                </span>
                                                            </td>
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px;">
                                                                    <br><br><br>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px; margin-top: 20px;">
                                                                    <b>SIGNATURE OF THE STUDENT</b>
                                                                </span>
                                                            </td>
                                                            <td width="50%" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>SIGNATURE OF THE PARENT</b>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: center;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br>
                                                                    <b>APPROVING AUTHORITY</b>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: center;">
                                                            <br /><br /><br />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    public static function certmenufilled($course, $feedata)
    {
        $_POST["course"]= $course;
        $year = static::certdata($_POST["course"]);
        $a = "";
        $fee = Homem::getdata("SELECT * FROM `fee_types`");
        $a .= '
            <table width="90%" align="center" style="border: 2px single black;">';
        $a .= '<thead>';
        $a .= '<tr style="text-align: center;">';
        $a .= '<th style="border: thin solid black">S. No.</th>';
        $a .= '<th style="border: thin solid black">Certificate Details</th>';
        $a .= '<th style="border: thin solid black">Original</th>';
        $a .= '<th style="border: thin solid black">Photocopy</th>';
        $a .= '</tr>';
        $a .= '</thead>';
        $a .= '<tbody>';
        for($i=0; $i<sizeof($year); $i++)
        {
            $j = $i+1;
            $a .= '<tr style="text-align: left;">';
            $a .= '<td style="border: thin solid black">'.$j.'</td>';
            $a .= '<td style="border: thin solid black">'.$year[$i].'</td>';
            $a .= '<td style="border: thin solid black"><span style="text-align: center;">'.$feedata["o"][$i].'</span></td>';
            $a .= '<td style="border: thin solid black">'.$feedata["d"][$i].'</td>';
            $a .= '</tr>';
        }
        $a .= '</tbody>';
        $a .= '</table>';
        return $a;
    }
    public static function feefixing()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master` WHERE `status`='1'"), 'id', 'name');
            $category = Inputs::optionsdb(Homem::getdata("SELECT * FROM `category`"), 'id', 'name');
            $quota = Inputs::optionsdb(Homem::getdata("SELECT * FROM `squota`"), 'sqid', 'sqname');
            $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_admissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.feedetails!='' ORDER BY a.id DESC ");
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Application Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/feefixingrecieptprint', 'id', '');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/savefeefixing" 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">
                                                <h4 class="title pull-left">FEE DETAILS ENTRY</h4>
                                                <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">                                      
                                                            <input type="text" name="no" id="no" class="form-control" placeholder="Application Reciept No." onchange="getapplicationdetails()" required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <select name="quota" id="quota" class="form-control" required>
                                                            <option value="">Admission Quota</option>
                                                            ';
                                                            echo $quota;
                                                            echo '
                                                        </select>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="category" id="category" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Select Category</option>
                                                            ';
                                                            echo $category;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name" readonly required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="swmobile" id="swmobile" class="form-control" placeholder="Student WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pname" id="pname" class="form-control" placeholder="Parent Name as per SSC">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pmobile" id="pmobile" class="form-control" placeholder="Parent Mobile Number">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pwmobile" id="pwmobile" class="form-control" placeholder="Parent WhatsApp Number">
                                                        </div>
                                                    </div> 
                                                    
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <select name="cetname" id="cetname" class="form-control" required>
                                                            <option value="">Select Exam Type</option>
                                                            '.static::cetname().'
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="hallticket" id="hallticket" class="form-control" placeholder="Hall Ticket Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="rank" id="rank" class="form-control" placeholder="Rank">
                                                        </div>
                                                    </div> 
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>   
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="year" id="year" class="form-control" placeholder="Admission Year" required>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <div id="feedetails"></div>
                                                        </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>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            function getJsonSize(json) 
            {
              var size = 0;
              for (var key in json) {
                if (json.hasOwnProperty(key)) {
                  size++;
                }
              }
              return size;
            }
            function getapplicationdetails()
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/getapplicationdetails",
                    type: "post",
                    data: {no:no},
                    success: function(d) {
                        {
                            const a = JSON.parse(d);
                            document.getElementById("sname").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("course").value = a[0]["fk_course_id"];
                            document.getElementById("department").value = a[0]["fk_dept_id"];
                            
                            if (a[0] && typeof a[0]["category"] !== "undefined") 
                            {
                                document.getElementById("category").value = a[0]["category"];
                            }
                            if (a[0] && typeof a[0]["year"] !== "undefined") 
                            {
                                document.getElementById("year").value = a[0]["year"];
                            }
                            if (a[0] && typeof a[0]["department"] !== "undefined") 
                            {
                                document.getElementById("department").value = a[0]["department"];
                            }
                            if (a[0] && typeof a[0]["course"] !== "undefined") 
                            {
                                document.getElementById("course").value = a[0]["course"];
                            }
                            if (a[0] && typeof a[0]["rank"] !== "undefined") 
                            {
                                document.getElementById("rank").value = a[0]["rank"];
                            }
                            if (a[0] && typeof a[0]["hallticket"] !== "undefined") 
                            {
                                document.getElementById("hallticket").value = a[0]["hallticket"];
                            }
                            if (a[0] && typeof a[0]["cetname"] !== "undefined") 
                            {
                                document.getElementById("cetname").value = a[0]["cetname"];
                            }
                            if (a[0] && typeof a[0]["pwmobile"] !== "undefined") 
                            {
                                document.getElementById("pwmobile").value = a[0]["pwmobile"];
                            }
                            if (a[0] && typeof a[0]["pmobile"] !== "undefined") 
                            {
                                document.getElementById("pmobile").value = a[0]["pmobile"];
                            }
                            if (a[0] && typeof a[0]["pname"] !== "undefined") 
                            {
                                document.getElementById("pname").value = a[0]["pname"];
                            }
                            if (a[0] && typeof a[0]["swmobile"] !== "undefined") 
                            {
                                document.getElementById("swmobile").value = a[0]["swmobile"];
                            }
                            if (a[0] && typeof a[0]["mobile"] !== "undefined") 
                            {
                                document.getElementById("mobile").value = a[0]["mobile"];
                            }
                            if (a[0] && typeof a[0]["sname"] !== "undefined") 
                            {
                                document.getElementById("sname").value = a[0]["sname"];
                            }
                            if (a[0] && typeof a[0]["quota"] !== "undefined") 
                            {
                                document.getElementById("quota").value = a[0]["quota"];
                            }
                            if (a[0] && typeof a[0]["pwmobile"] !== "undefined") 
                            {
                                document.getElementById("pwmobile").value = a[0]["pwmobile"];
                            }
                            getadmissionyear();
                            getfeedetails(a[0]["fk_course_id"]);
                            setTimeout(function() {
                            if (a[0] && typeof a[0]["feedetails"] !== "undefined") 
                            {
                                const b = JSON.parse(a[0]["feedetails"]);
                                // console.log(getJsonSize(b["fee"]));
                                for(i=1; i<=getJsonSize(b["fee"]); i++)
                                {
                                    for(j=1; j<=getJsonSize(b["fee"][i]); j++)
                                    {
                                        // console.log(b["fee"][i][j]);
                                        var elementId = "fee[" + i + "][" + j + "]";
                                        document.getElementById(elementId).value = b["fee"][i][j];
                                        // setTimeout(function() {
                                        //     console.log("This message will be logged after 2000 milliseconds (2 seconds).");
                                        // }, 2000);
                                    }
                                }
                            }
                            }, 1000);
                        }
                    }
                });
            }
            function getfeedetails(course)
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/feemenu",
                    type: "post",
                    data: {course:course},
                    success: function(d) {
                        {
                            document.getElementById("feedetails").innerHTML = d;
                            // alert(d);
                        }
                    }
                });
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    public static function savefeefixing()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
        foreach ($_POST as $key => $value)
        {
            if($key == 'fee')
            {
		        $info[$key]=$value;
            }
            else
            {
                $infoo[$key]=$value;
            }
	    }
	    $info1 = json_encode($info);
	    $infoo1 = json_encode($infoo);
	    Homem::insert("UPDATE `stdnt_admissionfee` SET `name`='$_POST[sname]', `mobile`='$_POST[mobile]', `fk_course_id`='$_POST[course]', `fk_dept_id`='$_POST[department]', `year`='$_POST[year]', `pmobile`='$_POST[pmobile]', `quota`='$_POST[quota]', `extra` ='$infoo1', `feedetails`='$info1' WHERE `receipt_no`='$_POST[no]'");
        echo '<script>window.location = "/Admissions/feefixing?status=1";</script>';
        }
	    
    }
    public static function feefixingrecieptprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * from `stdnt_admissionfee` WHERE `id`='$_GET[editid]'");
                $extra = json_decode($data[0]["extra"], true);
                $feedetails = json_decode($data[0]["feedetails"], true);
                $a = static::feemenufilled($extra["course"], $feedetails["fee"]);
                // echo count($feedetails["fee"]);
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::feefixingheader().'
                                                    </tbody>
                                                </table>
                                                <table width="100%" style="margin-top:20px;">
                                                    <tbody>
                                                        <tr>
                                                            <td width="60%"><span style="margin-left: 10px;">Provisional Admission Number: <b>'.$data[0]['fk_stdntenquiry_id'].'</b></span></td>
                                                            <td width="40%" style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['regdate']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2"><span style="margin-left: 10px;">Admission Number: ______________</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2"><span style="margin-left: 10px;">Registration / PIN Number: ______________</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Name of the Student</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["sname"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Name of the Parent</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pname"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Course & Department</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::course($extra["course"]).' - '.static::dept($extra["department"]).'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                            <span style="margin-left: 10px;">CET Name</span>
                                                        </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["cetname"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Hallticket No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["hallticket"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Rank</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["rank"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Student Mobile No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["mobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Student WhatsApp No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["swmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Parent Mobile No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Parent WhatsApp No</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.$extra["pwmobile"].'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Category</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::cat($extra["category"]).'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                        <tr style="text-align: left;">
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">Admission Type</span>
                                                            </td>
                                                            <td width="50%" style="border: thin solid black">
                                                                <span style="margin-left: 10px;">'.static::quotaa($extra["quota"]).'</span>
                                                            </td>
                                                        </tr>
                                                        
                                                    </tbody>
                                                </table>
                                                
                                                <table width="90%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="3">
                                                                <span style="margin-left: 50px;"><b>Fee Details: </b></span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                '.$a.'
                                                <table width="100%">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px;">
                                                                    <br><br><br>
                                                                </span>
                                                            </td>
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px;">
                                                                    <br><br><br>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td width="50%" style="text-align: left;">
                                                                <span style="margin-left: 10px; margin-top: 20px;">
                                                                    <b>SIGNATURE OF THE STUDENT</b>
                                                                </span>
                                                            </td>
                                                            <td width="50%" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>SIGNATURE OF THE PARENT</b>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: center;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br>
                                                                    <b>APPROVING AUTHORITY</b>
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: center;">
                                                            <br /><br /><br />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    private static function feefixingheader()
    {
        if($_SESSION['org_id'] == 1)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>HINDU COLLEGE, GUNTUR</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 2)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 3)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Engineering & Technology</h1>
                    <h5>Approved by AICTE, New Delhi and Affiliated to JNTUK, kakinada & APSBTET</h5>
                    <h5>Amaravathi Road, Guntur-522002</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 4)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 5)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Management</h1>
                    <h5>Amaravathi Road, Guntur-522002, Andhra Pradesh</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 6)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">REGISTRATION FORM FOR ADMISSIONS</a>
                </td>
            </tr>
            ';
        }
    }
    public static function feemenufilled($course, $feedata)
    {
        $_POST["course"]= $course;
        $year = static::years($_POST["course"]);
        $a = "";
        $fee = Homem::getdata("SELECT * FROM `fee_types`");
        $a .= '
            <table width="90%" align="center" style="border: 2px single black;">';
        $a .= '<thead>';
        $a .= '<tr style="text-align: center;">';
        $a .= '<th style="border: thin solid black">Year</th>';
        for($j=0; $j<sizeof($fee); $j++)
        {
            $a .= '<th style="border: thin solid black">';
            $a .= $fee[$j]["f_name"];
            $a .= '</th>';
        }
        $a .= '</tr>';
        $a .= '</thead>';
        $a .= '<tbody>';
        for($i=1; $i<=$year; $i++)
        {
            $a .= '<tr style="text-align: center;">';
            $a .= '<td style="border: thin solid black">'.static::yearname($i).'</td>';
            for($j=0; $j<sizeof($fee); $j++)
            {
                $k =$j+1;
                $a .= '<td style="border: thin solid black">'.$feedata[$i][$k].'</td>';
            }
            $a .= '</tr>';
        }
        $a .= '</tbody>';
        $a .= '</table>';
        return $a;
    }
    public static function feemenu()
    {
        $year = static::years($_POST["course"]);
        $a = "";
        $fee = Homem::getdata("SELECT * FROM `fee_types`");
        $a .= '<div class="table-responsive">
            <table class="table table-responsive-sm">';
        $a .= '<thead>';
        $a .= '<tr>';
        $a .= '<th>Year</th>';
        for($j=0; $j<sizeof($fee); $j++)
        {
            $a .= '<th>';
            $a .= $fee[$j]["f_name"];
            $a .= '</th>';
        }
        $a .= '</tr>';
        $a .= '</thead>';
        $a .= '<tbody>';
        for($i=1; $i<=$year; $i++)
        {
            $a .= '<tr>';
            $a .= '<td>'.static::yearname($i).'</td>';
            for($j=0; $j<sizeof($fee); $j++)
            {
                $k =$j+1;
                $a .= '<td><input type="text" name="fee['.$i.']['.$k.']" id="fee['.$i.']['.$k.']" class="form-control" required></td>';
            }
            $a .= '</tr>';
        }
        $a .= '</tbody>';
        $a .= '</table></div>';
        echo $a;
    }
    public static function yearname($id)
    {
        if($id == 1)
        {
            return "I- Year";
        }
        if($id == 2)
        {
            return "II- Year";
        }
        if($id == 3)
        {
            return "III- Year";
        }
        if($id == 4)
        {
            return "IV- Year";
        }
    }
    public static function years($d)
    {
        if($_SESSION["org_id"] == "1")
        {
            if($d != 4 && $d != 5)
            {
                return "4";
            }
            if($d == 4 || $d == 5)
            {
                return "2";
            }
        }
        if($_SESSION["org_id"] == "3")
        {
            if($d == 1)
            {
                return "3";
            }
            if($d == 2)
            {
                return "4";
            }
        }
        if($_SESSION["org_id"] == "4")
        {
            if($d == 1)
            {
                return "2";
            }
        }
        if($_SESSION["org_id"] == "5")
        {
            if($d == 1)
            {
                return "2";
            }
        }
    }
    // Fee Fixation code end
    
    // Print Online Fee Start
    public static function provisionaladdmissionfeeprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            {
                $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_provisionaladmissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.receipt_no!='' ORDER BY a.id DESC");
            }
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Reciept Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/provisionalfeerecieptprint', 'id', '');
            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">
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3"></div>
                        </div>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            function getapplicationdetails()
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/getapplicationdetails",
                    type: "post",
                    data: {no:no},
                    success: function(d) {
                        {
                            const a = JSON.parse(d);
                            document.getElementById("sname").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("course").value = a[0]["fk_course_id"];
                            document.getElementById("department").value = a[0]["fk_dept_id"];
                            getadmissionyear();
                        }
                    }
                });
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    // Print Online Fee End
    // Admissions Enquiry Code start
    
    public static function provisionaladdmissionfee()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {

            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_provisionaladmissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.fk_user_id=$_SESSION[user_id] AND a.receipt_no!='' ORDER BY a.id DESC ");
            if($_SESSION['user_role'] == 6)
            {
                $blood = Homem::getdata("SELECT a.*, b.code as course, c.code as dept FROM stdnt_provisionaladmissionfee a JOIN degree_name_master b ON a.fk_course_id=b.id JOIN degree_dept_master c ON a.fk_dept_id=c.id WHERE a.receipt_no!='' ORDER BY a.id DESC");
            }
            $table = Form::dbtableprint($blood, ['Name of The Student', 'Course', 'Branch', 'Mobile Number', 'Reciept Number', 'Amount', 'Date'], ['name', 'course', 'dept', 'mobile', 'receipt_no', 'amount', 'regdate'], '/Admissions/provisionalfeerecieptprint', 'id', '');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Admissions/saveprovisionaladdmissionfee" 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">
                                                <h4 class="title pull-left">PROVISIONAL ADMISSION FEE PAYMENT</h4>
                                                <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">                                      
                                                            <input type="text" name="no" id="no" class="form-control" placeholder="Application Reciept No." onchange="getapplicationdetails()" required>
                                                        </div>
                                                    </div> 
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name" readonly required>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="amount" id="amount" class="form-control" placeholder="Amount" required>
                                                        </div>
                                                    </div>
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" required>
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" onchange="getadmissionyear()" required>
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>   
                                                    <div class="col-lg-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="year" id="year" class="form-control" placeholder="Admission Year" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                    <div class="form-group">   
                                                        <select name="feemode" id="feemode" class="form-control" required>
                                                            <option value="">Select Mode of Payment</option>
                                                            '.$feemode.'
                                                        </select>
                                                    </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>';
                        echo '
                        <div class="row">
                            <div class="col-lg-3">
                            </div>
                            <div class="col-lg-6">
                            '.$table.'
                            </div>
                            <div class="col-lg-3">
                            </div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script>
            function getadmissionyear()
            {
                $("#year").val("'.date('Y').'");
            }
            function getapplicationdetails()
            {
                var no = $("#no").val();
                $.ajax({
                    url: "/Admissions/getapplicationdetails",
                    type: "post",
                    data: {no:no},
                    success: function(d) {
                        {
                            const a = JSON.parse(d);
                            document.getElementById("sname").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("course").value = a[0]["fk_course_id"];
                            document.getElementById("department").value = a[0]["fk_dept_id"];
                            getadmissionyear();
                        }
                    }
                });
            }
            </script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    public static function saveprovisionaladdmissionfee()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $recieptno = static::provisionaladmissionnumbercaluclator($_POST['year']);
            Homem::insert("INSERT INTO `stdnt_provisionaladmissionfee` (`id`, `name`, `mobile`, `fk_course_id`, `fk_dept_id`, `amount`, `fk_stdntenquiry_id`, `receipt_no`, `feemode`, `fk_user_id`, `regdate`, `status`) VALUES 
            (NULL, '$_POST[sname]', '$_POST[mobile]', '$_POST[course]', '$_POST[department]', '$_POST[amount]', '$_POST[no]', '$recieptno', '$_POST[feemode]', '$_SESSION[user_id]', '$date', '1')");
            static::sendsmsactive($_POST['sname'], $_POST['amount'], static::datem($date), $recieptno, $_POST['mobile']);
            echo '<script>window.location = "/Admissions/provisionaladdmissionfee?status=1";</script>';
        }
    }


    public static function provisionalfeerecieptprint()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * from `stdnt_provisionaladmissionfee` WHERE `id`='$_GET[editid]'");
                $text = static::numtotext($data[0]['amount']);
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::recieptheader().'
                                                        <tr>
                                                            <td><span style="margin-left: 10px;">Reciept Number: '.$data[0]['receipt_no'].'</span></td>
                                                            <td style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['regdate']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Name : &nbsp; </b>'.$data[0]['name'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Department :  &nbsp; </b>'.static::course($data[0]['fk_course_id']).'-'.static::dept($data[0]['fk_dept_id']).'</span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                <b>Fee Particulars</b>
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                <b>Amount (Rs.)</b>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                Provisional Admission Fee
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                '.number_format($data[0]['amount'], 2).'
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="2">
                                                                <span style="margin-left: 10px;"><b>Amount in words: </b>'.static::numtotext($data[0]['amount']).'</span>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <span style="margin-right: 10px;">
                                                                    <b>Mode of payment: </b> Cash
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>Office Inchage / Accountant </b> <br>('.$_SESSION['name'].')
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    public static function getapplicationdetails()
    {
        if(isset($_POST["no"]))
        {
            // echo $_POST["no"];
            $data = Homem::getdata("SELECT * FROM `stdnt_admissionfee` WHERE `fk_stdntenquiry_id`='$_POST[no]'");// `receipt_no`='$_POST[no]' OR
            if(sizeof($data)==1 && $data[0]["extra"] != "")
            {
                $json = $data[0]["extra"];
                $data1 = json_decode($json, true);
                $keys = array_keys($data1);
                for($i=0; $i<sizeof($keys); $i++)
                {
                    $data[0][$keys[$i]] = $data1[$keys[$i]];
                }
            }
            echo json_encode($data);
        }
    }
    public static function addadmissionnquiry()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $blood = Inputs::optionsdb(Homem::getdata("SELECT * FROM `blood_group`"), 'id', 'name');
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $category = Inputs::optionsdb(Homem::getdata("SELECT * FROM `category`"), 'id', 'name');
            $cast = Inputs::optionsdb(Homem::getdata("SELECT * FROM `cast` WHERE `status`='1'"), 'id', 'name');
            $subcast = Inputs::optionsdb(Homem::getdata("SELECT * FROM `cast_sub` WHERE `status`='1'"), 'id', 'name');
            $religion = Inputs::optionsdb(Homem::getdata("SELECT * FROM `religion` WHERE `status`='1'"), 'id', 'name');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Accounts/saveaddadmissionnquiry" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h4 class="title pull-left">ADD NEW STUDENT ENQUIRY</h4>
                                                <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-12">
                                                        Mandatory Fields*
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="sname" id="sname" class="form-control" placeholder="Student Name" required>
                                                        </div>
                                                    </div>      
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                   
                                                            <input type="text" name="dob" id="dob" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Date of Birth">
                                                        </div>
                                                    </div>                          
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                   
                                                            <select name="gender" id="gender" class="form-control" >
                                                                <option value="">Select Gender</option>    
                                                                <option value="M">Male</option>
                                                                <option value="F">Female</option>
                                                                <option value="O">Other</option>
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="blood" id="blood" class="form-control">
                                                            <option value="">Select Blood Group</option>
                                                            '; 
                                                            echo $blood;
                                                            echo '</select>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="religion" id="religion" class="form-control">
                                                            <option value="">Select Religion</option>
                                                            '; 
                                                            echo $religion;
                                                            echo '</select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                   
                                                            <select name="category" id="category" class="form-control" >
                                                                <option value="">Select Category</option>
                                                            '; 
                                                            echo $category;
                                                            echo '</select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="cast" id="cast" class="form-control">
                                                            <option value="">Select Cast</option>
                                                            '; 
                                                            echo $cast;
                                                            echo '</select>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="subcast" id="subcast" class="form-control">
                                                            <option value="">Select Sub-Cast</option>
                                                            '; 
                                                            echo $subcast;
                                                            echo '</select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="smobile" id="smobile" class="form-control" placeholder="Student Mobile Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="swmobile" id="swmobile" class="form-control" placeholder="Whatsapp Number">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="semail" id="semail" class="form-control" placeholder="Email">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="fname" id="fname" class="form-control" placeholder="Father Name">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="fmobile" id="fmobile" class="form-control" placeholder="Father Mobile">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="foccupation" id="foccupation" class="form-control" placeholder="Father Occupation">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mname" id="mname" class="form-control" placeholder="Mother Name">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mmobile" id="mmobile" class="form-control" placeholder="Mother Mobile">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="moccupation" id="moccupation" class="form-control" placeholder="Mother Occupation">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="address" id="address" class="form-control" placeholder="Address">
                                                        </div>
                                                    </div>  									
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="city" id="city" class="form-control" placeholder="City">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="pincode" id="pincode" class="form-control" placeholder="Pin Code">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="physical" id="physical" class="form-control">
                                                            <option value="">Physically Handicaped?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="addreservation" id="addreservation" class="form-control">
                                                            <option value="">Additional Resorvation?</option>
                                                            <option value="1">Sports</option>
                                                            <option value="2">NCC</option>
                                                            <option value="3">NSS</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="income" id="income" class="form-control" placeholder="Annual Income">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="feeremberse" id="feeremberse" class="form-control">
                                                            <option value="">Eligible for Fee Reembersment?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="ews" id="ews" class="form-control">
                                                            <option value="">Economically Weaker Section (EWS)?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">   
                                                            <select name="hostel" id="hostel" class="form-control">
                                                            <option value="">Hostel Requiremnet?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">
                                                            <select name="transport" id="transport" class="form-control">
                                                            <option value="">Bus Requiremnet?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                
                                                
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="psname" id="psname" class="form-control" placeholder="Present Studying School / College Name">
                                                        </div>
                                                    </div>  										
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="htno" id="htno" class="form-control" placeholder="Hallticket Number">
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="per" id="per" class="form-control" placeholder="Percentage">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="ypass" id="ypass" class="form-control" placeholder="Year of Pass">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="gap" id="gap" class="form-control">
                                                            <option value="">Is there any gap in education?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="gapyears" id="gapyears" class="form-control" placeholder="No Years of Gap">
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="exam" id="exam" class="form-control">
                                                            <option value="">Is there any Qulaifying Exam?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="examq" id="examq" class="form-control">
                                                            <option value="">Is exam qualified?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="adtype" id="adtype" class="form-control">
                                                            <option value="">Admission Type</option>
                                                            <option value="C">Convener Quota</option>
                                                            <option value="M">Management Quota</option>
                                                            <option value="S">Spot Admisssion</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="entrytype" id="entrytype" class="form-control">
                                                            <option value="">Admission Category?</option>
                                                            <option value="D">Direct Admission</option>
                                                            <option value="L">Lateral Admission</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control" multiple="multiple">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control" multiple="multiple">
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="enquiredby" id="enquiredby" class="form-control" placeholder="Enquired By">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <select name="confirm" id="confirm" class="form-control" >
                                                            <option value="">Will Admission is Confirmed?</option>
                                                            <option value="Y">Yes</option>
                                                            <option value="N">No</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <select name="sdepartment" id="sdepartment" class="form-control">
                                                            <option value="">Suggested Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="aftercourse" id="aftercourse" class="form-control" placeholder="After this Course?">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="joinerwiths" id="joinerwiths" class="form-control" placeholder="Joiner with Student">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-4">  
                                                        <div class="form-group">
                                                            <input type="text" name="howabtus" id="howabtus" class="form-control" placeholder="How you know us?">
                                                        </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-2"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            echo '<script></script>';
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    
    public static function provisionaladmissionnumbercaluclator($no)
    {
        $no2 = (int)$no-2000+1;
        $no = $no.'-'.$no2.'-';
        $data = Homem::getdata("SELECT * FROM `stdnt_provisionaladmissionfee` WHERE `receipt_no` LIKE '%$no%'");
        $no1 = sizeof($data)+1;
        return $no.$no1;
    }
    // Admissions Enquiry Code end
    // SMS SENDING CODE START
    private static function smscredits()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/Balance?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        curl_close($curl);
        echo $response;
    }
    private static function approvedsenderids()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/SenderId?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    private static function approvedtemplates()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/Template?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    private static function sendsms()
    {
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.mylogin.co.in/api/v2/SendSMS?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553&SenderId=HNDGNT&Message=Dear%20kRISHNARJUNA%20RAO,%20we%20received%20an%20amount%20of%20Rs.5000%20on%2007-07-2021%20as%20tuition%20fee%20from%20you.%20Please%20note%20down%20receipt%20number%202017-1%20for%20future%20reference-HCHSC&MobileNumbers=919494470239&Is_Unicode=false&Is_Flash=false',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        echo $response;
    }
    private static function sendsmsactive($name, $amount, $date, $receiptno, $mobile)
    {
        $name = static::shortname($name);
        $amount = $amount;
        $date = $date;
        $receiptno = $receiptno;
        $mobile = $mobile;
        $input = 'Dear '.$name.', we received an amount of Rs.'.$amount.' on '.$date.' as tuition fee from you. Please note down receipt number '.$receiptno.' for future reference-HCHSC';
        $url = 'https://api.mylogin.co.in/api/v2/SendSMS?ApiKey=9FYw45bZk/traX4phb0DCEb9KFiQkNOD8suGLWVgzK8=&ClientId=38ee5f8c-f4e9-42a3-b671-9a8f02121553&SenderId=HNDGNT&Message='.rawurlencode($input).'&MobileNumbers=91'.$mobile.'&Is_Unicode=false&Is_Flash=false';
        $curl = curl_init();
        curl_setopt_array($curl, array(
          CURLOPT_URL => $url,
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));
        
        $response = curl_exec($curl);
        
        curl_close($curl);
        // echo $response;
        return 1;
    }
    private static function shortname($name)
    {
        $size =  strlen($name);
        if($size<50)
        {
            return $name;
        }
        else
        {
            return 'Son/Daughter';
        }
        
    }
    private static function testsms()
    {
        echo static::sendsmsactive('KRISHNARJUNA SUDA', '1000', '08-08-2011', '2021', '9494470239');
    }
    // SMS SENDING CODE END
    // testing for edit
    public static function indstdntfeereport()
    {
        if($_SESSION['org_id'] == 1)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }
        if($_SESSION['org_id'] == 2)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }
        if($_SESSION['org_id'] == 3)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                    <h1>Hindu College of Engineering & Technology</h1>
                    <h5>Approved by AICTE, New Delhi and Affiliated to JNTUK, kakinada & APSBTET</h5>
                    <h5>Amaravathi Road, Guntur-522002</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }
        if($_SESSION['org_id'] == 4)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }
        if($_SESSION['org_id'] == 5)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                <h1>Hindu College of Management</h1>
                <h5>Amaravathi Road, Guntur-522002, Andhra Pradesh</h5>
                <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }
        if($_SESSION['org_id'] == 6)
        {
            return 
            '
            <tr style="text-align: center;">
                <th colspan="1">
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </th>
                <th colspan="7">
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Individual Student Fee Payment Details</a>
                </th>
            </tr>';
        }

    }
    private static function recieptheader()
    {
        if($_SESSION['org_id'] == 1)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>HINDU COLLEGE, GUNTUR</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 2)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 3)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Engineering & Technology</h1>
                    <h5>Approved by AICTE, New Delhi and Affiliated to JNTUK, kakinada & APSBTET</h5>
                    <h5>Amaravathi Road, Guntur-522002</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 4)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 5)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College of Management</h1>
                    <h5>Amaravathi Road, Guntur-522002, Andhra Pradesh</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
        if($_SESSION['org_id'] == 6)
        {
            return '
            <tr style="text-align: center;">
                <td>
                    <img src="https://assets.hinduengg.com/hindu/assets/img/logo-1.png" width="150px" height="150px">
                </td>
                <td>
                    <h1>Hindu College</h1>
                    <h5>(Re-accredited by NAAC as Grade ‘A’ with CGPA 3.07)</h5>
                    <h5>Main Road, Opp. Sri Venkateswara Vignan Mandir, Guntur Ph.: 0863-2227649</h5>
                    <a style="border: solid 1px black; border-radius: 10px; padding: 5px; font-size: 20px;">Receipt</a>
                </td>
            </tr>
            ';
        }
    }
    private static function recieptfront()
    {
        date_default_timezone_set('Asia/Kolkata'); 
        $date =  date('ym'); 
        return $date;
    }
    public static function recieptno()
    {
        date_default_timezone_set('Asia/Kolkata'); 
        $date =  date('Y-m-');
        
        // $query = "SELECT * FROM `stdnt_normalfee` WHERE `entry_date`='$date'";
        $query = "SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'";
        $data = Homem::getdata($query);
        $count = sizeof($data);
        $new = $count+1;
        $rno = static::recieptfront().'-'.$new;
        $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `recieptno`='$rno'");
        if(sizeof($data) == 0)
        {
            return $rno;
        }
        else
        {
            return 'retry';
        }

    }
    public static function getusernamemobileemail()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $data[0]['name']= '';
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `no`='$_POST[no]'");
            echo json_encode($data);
        }
    }
    public static function addcoplayerinner()
    {
        echo '
        <div class="bootstrap-modal">
          <div class="modal fade" id="addcoplayerinner" role="dialog">
            <div class="modal-dialog">
            
              <!-- Modal content-->
              <div class="modal-content">
              <div class="modal-header">
                    <h5 class="modal-title">Update Student Contact Information</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>×</span>
                    </button>
                </div>
                <div class="modal-body">
                <div class="row" >
                  <div class="col-md-12">
                    <div class="form-group">
                        <input type="hidden" name="id" id="id" class="form-control" placeholder="Student ID*" required>
                        <input type="text" name="sno" id="sno" class="form-control" placeholder="Hallticket Number*" required>
                    </div>
                    <div class="form-group">
                        <input id="sname" type="text" name="sname" class="form-control" placeholder="Full Name in Block Letters*" required="required"/>
                    </div>
                  </div>
                </div>
                <div class="row" >
                  <div class="col-md-6">
                    <div class="form-group">
                      <select name="gender" id="gender" class="form-control">
                        <option value="">Select Gender</option>
                        <option value="M">Male</option>
                        <option value="F">Female</option>
                        </select>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                        <input type="text" name="dob" id="dob" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Date of Birth" required="">
                    </div>
                  </div>
                </div>
                <div class="row" >
                  <div class="col-md-6">
                    <div class="form-group">
                      <input id="semail" type="email" name="semail" class="form-control" placeholder="Mobile *" required="required" />
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                        <input id="smobile" type="number" name="smobile" class="form-control" placeholder="Student Mobile*" required="required" />
                    </div>
                  </div>
                </div>
            <div class="row" >
                <div class="col-md-6">
                  <div class="form-group">
                    <input id="fname" type="text" name="fname" class="form-control" placeholder="Parent Name *" required="required" />
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-group">
                      <input id="fmobile" type="number" name="fmobile" class="form-control" placeholder="Parent Mobile*" required="required" />
                  </div>
                </div>
              </div>
                <!--
                <div class="row" >
                  <div class="col-md-12">
                    <div class="form-group">
                      <input id="address" name="address" class="form-control" placeholder="Address *" required />
                    </div>
                  </div>
                </div>
                -->
                </div>
                <div class="modal-footer">
                    <div class="form-group"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div>
                    <div class="form-group"><button type="button" id="SaveNewCoplayer" class="btn btn-primary" onclick="snewcoplayer()">Save</button></div>
                </div>
              </div>
              
            </div>
          </div>
          </div>
        ';
        echo '
            <script>
                function snewcoplayer() 
                { 
                    var sid = document.getElementById("id");
                    var sno = document.getElementById("sno");
                    var sname = document.getElementById("sname");
                    var gender = document.getElementById("gender");
                    var dob = document.getElementById("dob");
                    var smobile = document.getElementById("smobile");
                    var semail = document.getElementById("semail");
                    var fname = document.getElementById("fname");
                    var fmobile = document.getElementById("fmobile");
                    if(sid.value==""){$("#sid").focus();}
                    else if(sno.value==""){$("#sno").focus();}
                    else if(sname.value==""){$("#sname").focus();}
                    else if(gender.value==""){$("#gender").focus();}
                    else if(dob.value==""){$("#dob").focus();}
                    else if(smobile.value==""){$("#smobile").focus();}
                    else if(semail.value==""){$("#semail").focus();}
                    else if(fname.value==""){$("#fname").focus();}
                    else if(fmobile.value==""){$("#fmobile").focus();}
                    else
                    {
                        $("#addcoplayerinner").modal("hide"); 
                        $.ajax({
                            url: "/Accounts/savesnewcoplayerinner",
                            type: "post",
                            data: {sid:sid.value, sno:sno.value, name: sname.value, gender:gender.value, dob:dob.value, mobile:smobile.value, email:semail.value, fname:fname.value, fmobile:fmobile.value},
                            success: function(d) {
                                if(d == "success")
                                {
                                    // alert(d);
                                    swal("Updated Successfully", "Please Click on Ok to Continue", "success");
                                    var delayMs = 500; // delay in milliseconds
                                    setTimeout(function(){
                                        window.location = "/Accounts/normalfeecolectnew?no="+sno.value;
                                    }, delayMs);
                                    
                                    // location.reload();
                                }
                                else
                                {
                                    // alert(d);
                                    swal("Not Updated", "Something went Wrong.. Please tryagain later..", "error");
                                    // var delayMs = 500; // delay in milliseconds
                                    // setTimeout(function(){
                                    //     $("#foundcoplayerinner").modal("show");
                                    // }, delayMs);
                                }
                            }
                        });
                    }
                }
            </script>';
    }
    public static function savesnewcoplayerinner()
    {
        if($_SESSION['user_id'] != '')
        {
            if($_POST['email'] != '' && $_POST['mobile'] != '')
            {
                $date = date('Y-m-d');
                $query = "UPDATE `user_master` SET `name`='$_POST[name]', `fname`='$_POST[fname]', `fmobile`='$_POST[fmobile]', `dob`='$_POST[dob]', `gender`='$_POST[gender]', `mobile`='$_POST[mobile]', `email`='$_POST[email]', `add_by`='$_SESSION[user_id]', `add_date`='$date' WHERE `id`='$_POST[sid]' AND `no`='$_POST[sno]'";
                Homem::insert($query);
                echo 'success';
            }
            else
            {
                echo 'fail';
            }
        }
    }
    public static function normalfeecolectnew()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 8)
        {
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $table = '';
            {
                $date = date('Y-m-d');
                // $blood = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE (`entry_date`='$date' OR `edit_date`='$date') AND (`entry_id`='$_SESSION[user_id]' OR `edit_id`='$_SESSION[user_id]') AND `fk_org_id`='$_SESSION[org_id]'");
                $blood = Homem::getdata("SELECT * FROM stdnt_normalfee sn JOIN user_master um ON um.id=sn.no WHERE (sn.entry_date='$date' OR sn.edit_date='$date') AND (sn.entry_id='$_SESSION[user_id]' OR sn.edit_id='$_SESSION[user_id]') AND sn.fk_org_id='$_SESSION[org_id]'");
                $table = Form::dbtableprint($blood, ['Admission Number', 'Hallticket Number', 'Name', 'Reciept Number', 'Paid Amount'], ['ano', 'no', 'name', 'recieptno', 'amount'], '/Accounts/print', 'nid', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Accounts/savenormalfeecolectnew" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Fee Payment Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly required>                                         
                                                    </div>
                                                </div>
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Student Mobile Number" readonly>                                         
                                                    </div>
                                                </div>
                                                
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="email" id="email" class="form-control" placeholder="Student Email" readonly required>                                         
                                                    </div>
                                                </div> 
                                                
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control" required>
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                            <option value="">Select Fee Type</option>
                                                            '.$feetype.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="dueamount" id="dueamount" class="form-control" placeholder="Due Amount" readonly>                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paidamount" id="paidamount" class="form-control" placeholder="Fee Amount" required>                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="recieptno" id="recieptno" class="form-control" placeholder="Reciept Number">                                         
                                                        <select name="feemode" id="feemode" class="form-control" required>
                                                            <option value="">Select Mode of Payment</option>
                                                            '.$feemode.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                    <input type="hidden" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Fee Paid Date"> 
                                                    <input type="text" name="remarks" id="remarks" class="form-control" placeholder="Remarks">                                   
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row" id="modifylink" style="display:none;">
                                                    <div class="col-lg-12">
                                                        <div class="float-lg-right"><a href="javascript:void(0);" onclick="updatecontactdetails()">Change Contact Information</a></div> 
                                                    </div>
                                            </div>
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group"> 
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="user id" required>
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                $(document).ready(function(){
                    var div = document.createElement("div");
                    div.id = "addcoplayerinner1";
                    document.getElementsByTagName("body")[0].appendChild(div);
                    $("#addcoplayerinner1").load("/Accounts/addcoplayerinner");
                });
                // $(document).ready(function(){
                //     var div = document.createElement("div");
                //     div.id = "foundcoplayerinner1";
                //     document.getElementsByTagName("body")[0].appendChild(div);
                //     $("#foundcoplayerinner1").load("/Accounts/foundcoplayerinner");
                // });
                function updatecontactdetails()
                {
                    $("#addcoplayerinner").modal("show");
                }
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusernamemobileemail",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            const a = JSON.parse(d);
                            document.getElementById("name").value = a[0]["name"];
                            document.getElementById("mobile").value = a[0]["mobile"];
                            document.getElementById("email").value = a[0]["email"];
                            if(a[0]["id"] != "")
                            {
                                $("#modifylink").show();
                            }
                            getuserid();
                            setTimeout(function(){ $("#id").val(a[0]["id"]); }, 500);
                            $("#id").val(a[0]["id"]);
                            $("#sno").val(a[0]["no"]);
                            $("#sname").val(a[0]["name"]);
                            $("#gender").val(a[0]["gender"]);
                            $("#dob").val(a[0]["dob"]);
                            $("#smobile").val(a[0]["mobile"]);
                            $("#semail").val(a[0]["email"]);
                            $("#fname").val(a[0]["fname"]);
                            $("#fmobile").val(a[0]["fmobile"]);
                        }
                    });
                }
                function getdueamount()
                {
                    var no = $("#no").val();
                    var year = $("#year").val();
                    var feetype = $("#feetype").val();
                    $.ajax({
                        url: "/Accounts/getdueamount",
                        type: "post",
                        data: {no: no, year: year, feetype: feetype},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("dueamount").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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>';
                }
            }
            if(isset($_GET['no']))
            {
                echo '
                    <script>
                        $("#no").val("'.$_GET['no'].'");
                        getusername();
                    </script>';
            }
        }
    }
    public static function savenormalfeecolectnew()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $_POST['paydate'] =$date;
            $_POST['recieptno'] = static::recieptno();
            if($_POST['recieptno'] != 'retry')
            {
                $_POST['recieptno'] = $_POST['recieptno'];
            
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `id`='$_POST[sid]' AND (`ano`='$_POST[no]' OR `no`='$_POST[no]')");
            $data1 = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `no`='$_POST[sid]' AND `year`='$_POST[year]' AND `fk_feetype_id`='$_POST[feetype]' AND `amount`='$_POST[paidamount]' AND `paid_date`='$_POST[paydate]'");
            if(sizeof($data) == 1)
            {
                if($_POST['edit_id'] == '')
                {
                    if(sizeof($data1) == 0)
                    {
                        Homem::insert("INSERT INTO `stdnt_normalfee` (`no`, `year`, `fk_feetype_id`, `amount`, `recieptno`, `fk_feemode_id`, `paid_date`, `remarks`, `fk_org_id`, `entry_date`, `entry_id`, `edit_date`, `edit_id`) VALUES 
                        ('$_POST[sid]', '$_POST[year]', '$_POST[feetype]', '$_POST[paidamount]', '$_POST[recieptno]', '$_POST[feemode]', '$_POST[paydate]', '$_POST[remarks]', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '', '')");
                        static::sendsmsactive($_POST['name'], $_POST['paidamount'], static::datem($date), $_POST['recieptno'], $_POST['mobile']);
                        echo '<script>window.location = "/Accounts/normalfeecolectnew?status=1";</script>';
                    }
                    else
                    {
                        echo '<script>window.location = "/Accounts/normalfeecolectnew?status=0";</script>';
                    }
                }
                else
                {
                    Homem::insert("UPDATE `stdnt_normalfee` SET `no`='$_POST[sid]', `year`='$_POST[year]', `fk_feetype_id`='$_POST[feetype]', `amount`='$_POST[paidamount]', `recieptno`='$_POST[recieptno]', `fk_feemode_id`='$_POST[feemode]', `paid_date`='$_POST[paydate]', `remarks`='$_POST[remarks]', `edit_date`='$date', `edit_id`='$_SESSION[user_id]' WHERE `nid`='$_POST[edit_id]'");
                    echo '<script>window.location = "/Accounts/normalfeecolectnew?status=2";</script>';
                }
            }
            }
            else
            {
                echo '<script>window.location = "/Accounts/normalfeecolectnew?status=0";</script>';
            }
        }
    }
    /* alter table user_master convert to character set utf8 collate utf8_general_ci;*/

    /** Common Table alterrations - must needed
     * ALTER TABLE `user_master` ADD `fname` INT NOT NULL AFTER `name`;
     * ALTER TABLE `user_master` ADD `lateral` VARCHAR(1) NOT NULL AFTER `fk_dept_id`;
     * ALTER TABLE `user_master` ADD `add_by` VARCHAR(22) NOT NULL AFTER `v_email`, ADD `add_date` VARCHAR(30) NOT NULL AFTER `add_by`;
     */

     /**
      * ALTER TABLE `user_master` ADD `discontinued` VARCHAR(1) NOT NULL AFTER `add_date`, ADD `tc_given` VARCHAR(1) NOT NULL AFTER `discontinued`;
      */
    /**
     * Student marks uploading bulk - started
     */
    public static function uploadstdmarksbulk()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4"> 
                                <form action="/Accounts/saveuploadstdmarksbulk" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Students Marks</h5>
                                                </header>
                                                <div class="content-body">    
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">                                      
                                                                <input type="file" name="file" id="file" class="form-control" placeholder="Category Name">
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">   
                                                                <input type="hidden" name="type" id="type" class="form-control" value="bulk" placeholder="Type">                                         
                                                                <a href="/hindu/formats/stdnt_marks_bulkupload_format.csv">Click Here to Download Uploading Format</a>
                                                            </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>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </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 saveuploadstdmarksbulk()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $date = date('Y-m-d');
            if($_POST['type'] == 'bulk')
            {
                $filename=$_FILES['file']['name'];
                $exts[0]='csv';
                $filetype1 = explode('.',$filename);
                if($_FILES['file']['name']!=null && $filetype1[sizeof($filetype1)-1] == $exts[0])
                {
                    $csv_file=$_FILES['file']['tmp_name'];
                    $size=$_FILES['file']['size'];
                    $handle = fopen($csv_file, "r");
                    $data = fgetcsv($handle, 100000, ",");
                    $i = 0;
                    while (($data = fgetcsv($handle, 100000, ","))!== FALSE)
                    {
                        $course = trim($data[0]);
                        $regulation = trim($data[1]);
                        $year = trim($data[2]);
                        $sem = trim($data[3]);
                        $htno = trim($data[4]);
                        $subcode = trim($data[5]);
                        $subname = trim($data[6]);
                        $grade = trim($data[7]);
                        $credits = trim($data[8]);
                        $resulttype = trim($data[9]);
                        $exammonth = trim($data[10]);
                        $examyear = trim($data[11]);
                        $paid_date = trim($data[12]);
                        $resultdate =static::datemodify($paid_date);
                        if($htno != '' && $subcode !='')
                        {
                            $query = "INSERT INTO `results_data` (`id`, `year`, `sem`, `ht_no`, `sub_code`, `sub_name`, `internal`, `external`, `grade`, `credit`, `exammonth`, `examyear`, `resultdate`, `result_type`, `examtype`, `fk_user_id`, `status`, `fk_org_id`, `fk_course_id`) VALUES (NULL, '$year', '$sem', '$htno', '$subcode', '$subname', '', '', '$grade', '$credits', '$exammonth', '$examyear', '$resultdate', '$resulttype', '$resulttype', '$_SESSION[user_id]', '1', '$_SESSION[org_id]', '$course')";
                            Homem::insert($query);
                            $i++;
                        }
                    }
                    echo '<script>window.location = "/Accounts/uploadstdmarksbulk?status=1&count='.$i.'";</script>';
                }
            }
        }
    }
    private static function month($id)
    {
        if($id != '')
        {
            if($id == 1)
            {
                return 'Jan';
            }
            if($id == 2)
            {
                return 'Feb';
            }
            if($id == 3)
            {
                return 'Mar';
            }
            if($id == 4)
            {
                return 'Apr';
            }
            if($id == 5)
            {
                return 'May';
            }
            if($id == 6)
            {
                return 'June';
            }
            if($id == 7)
            {
                return 'July';
            }
            if($id == 8)
            {
                return 'Aug';
            }
            if($id == 9)
            {
                return 'Sept';
            }
            if($id == 10)
            {
                return 'Oct';
            }
            if($id == 11)
            {
                return 'Nov';
            }
            if($id == 12)
            {
                return 'Dec';
            }
        }
    }
    private static function resulttype($id, $count)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1 && $count == 1)
            {
                return 'REG';
            }
            else if($id == 1 && $count > 1)
            {
                return 'SUP';
            }
            else if($id == 2)
            {
                return 'REV';
            }
            else
            {
                return 'REG/SUP';
            }
        }
    }
    private static function resultstatus($id, $course)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($id == 1 && $course == 2)
            {
                return 'FAIL';
            }
            if($id == 0 && $course == 2)
            {
                return 'PASS';
            }
        }
    }
    private static function yearandsem($year, $sem)
    {
        if($_SESSION['org_id'] == 3)
        {
            if($year == 1 && $sem == 1)
            {
                return 'First Year - First Sem';
            }
            if($year == 1 && $sem == 2)
            {
                return 'First Year - Second Sem';
            }
            if($year == 2 && $sem == 1)
            {
                return 'Second Year - First Sem';
            }
            if($year == 2 && $sem == 2)
            {
                return 'Second Year - Second Sem';
            }
            if($year == 3 && $sem == 1)
            {
                return 'Third Year - First Sem';
            }
            if($year == 3 && $sem == 2)
            {
                return 'Third Year - Second Sem';
            }
        }
    }
    public static function resulttest()
    {
        $data = Homem::getdata("SELECT rd.*, ugg.grade as gradepoint, ugg.failstatus FROM results_data rd JOIN ug_grademarks ugg ON ugg.level=rd.grade WHERE rd.ht_no='192x1a0501' ORDER BY rd.resultdate DESC");
        $crse = array();
        $yer = array();
        $sm = array();
        $subcode = array();
        $subname = array();
        $rdate = array();
        foreach ($data as $h) {
            $crse[] = $h['fk_course_id'];
            $yer[] = $h['year'];
            $sm[] = $h['sem'];
            $subcode[] = $h['sub_code'];
            $subname[] = $h['sub_name'];
            $rdate[] = $h['resultdate'];
        }
        $course = array_values(array_unique($crse));
        sort($course);
        $year = array_values(array_unique($yer));
        sort($year);
        $sem = array_values(array_unique($sm));
        sort($sem);
        $sub_code = array_values(array_unique($subcode));
        sort($sub_code);
        $sub_name = array_values(array_unique($subname));
        sort($sub_name);
        $resultdate = array_values(array_unique($rdate));
        sort($resultdate);
        for($i=0; $i<sizeof($sub_code); $i++)
        {
            for($j=0; $j<sizeof($data); $j++)
            {
                $sub_code_name[$sub_code[$i]] = $data[$j]['sub_code'];
            }
        }
        for($i=0; $i<sizeof($year); $i++)
        {
            for($j=0; $j<sizeof($sem); $j++)
            {
                $year_sem_sub[$year[$i]][$sem[$j]] = array();
                for($k=0; $k<sizeof($sub_code); $k++)
                {
                    for($l=0; $l<sizeof($data); $l++)
                    {
                        if($data[$l]['year'] == $year[$i] && 
                        $data[$l]['sem'] == $sem[$j] &&
                        $data[$l]['sub_code'] == $sub_code[$k])
                        {
                            $year_sem_sub[$year[$i]][$sem[$j]][] = $data[$l]['sub_code'];
                            $year_sem_sub1[$year[$i]][$sem[$j]][$data[$l]['sub_code']] = $data[$l]['sub_code'];
                            break;
                        }
                    }
                }    
            }
        }
        for($i=0; $i<sizeof($sub_code); $i++)
        {
            $a = 0;
            for($j=0; $j<sizeof($data); $j++)
            {
                if($data[$j]['sub_code'] == $sub_code[$i])
                {
                    if($a == 0)
                    {
                        $sub_data[$sub_code[$i]]['grade'] = $data[$j]['grade'];
                        $sub_data[$sub_code[$i]]['gradepoint'] = $data[$j]['gradepoint'];
                        $sub_data[$sub_code[$i]]['credit'] = $data[$j]['credit'];
                        $sub_data[$sub_code[$i]]['failstatus'] = $data[$j]['failstatus'];
                        $sub_data[$sub_code[$i]]['sub_name'] = $data[$j]['sub_name'];
                        $sub_data[$sub_code[$i]]['resultdate'] = $data[$j]['resultdate'];
                        $sub_data[$sub_code[$i]]['sub_code'] = $data[$j]['sub_code'];
                        $sub_data[$sub_code[$i]]['month'] = $data[$j]['exammonth'];
                        $sub_data[$sub_code[$i]]['year'] = $data[$j]['examyear'];
                        $sub_data[$sub_code[$i]]['examtype'] = $data[$j]['examtype'];
                    }
                    $a++;
                }
                if($j == sizeof($data)-1)
                {
                    if($a > 0)
                    {
                        $sub_data[$sub_code[$i]]['count'] = $a;
                    }
                }
            }
        }
        $a = '';
        $a .= '<div class="table-responsive" id="exporttable">';													
        $a .= '<table class="table table-responsive-sm print-this" border="1px">';
        if(sizeof($course) == 1)
        {
            if($course[0] == 2)
            {
                for($i=0; $i<sizeof($year); $i++)
                {
                    for($j=0; $j<sizeof($sem); $j++)
                    {
                        $b = 0;
                        for($k=0; $k<sizeof($sub_code); $k++)
                        {
                            if(sizeof($year_sem_sub[$year[$i]][$sem[$j]])>0)
                            {
                                if(isset($year_sem_sub1[$year[$i]][$sem[$j]][$sub_code[$k]]))
                                {
                                    if($b == 0)
                                    {
                                        $a .= '<tr><th colspan="10">'.static::yearandsem($year[$i], $sem[$j]).'</th></tr>';
                                        $a .= '<tr><th>Subject Code</th><th>Subject Name</th><th>Grade</th><th>Points</th><th>Credits</th><th>Month</th><th>Year</th><th>Type</th><th>Date</th><th>Status</th></tr>';
                                    }
                                    $a .= '<tr>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['sub_code'].'</td>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['sub_name'].'</td>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['grade'].'</td>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['gradepoint'].'</td>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['credit'].'</td>';
                                    $a .= '<td>'.static::month($sub_data[$sub_code[$k]]['month']).'</td>';
                                    $a .= '<td>'.$sub_data[$sub_code[$k]]['year'].'</td>';
                                    $a .= '<td>'.static::resulttype($sub_data[$sub_code[$k]]['examtype'], $sub_data[$sub_code[$k]]['count']).'</td>';
                                    $a .= '<td>'.static::datem($sub_data[$sub_code[$k]]['resultdate']).'</td>';
                                    $a .= '<td>'.static::resultstatus($sub_data[$sub_code[$k]]['failstatus'], $course[0]).'</td>';
                                    $a .= '</tr>';
                                    $b++;
                                }
                            }
                        }
                    }
                }
            }
        }
        $a .= '</tbody>';
        $a .= "</table>";
        $a .= "</div>";
        $a .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-12"> 
                                <form action="" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Students Marks</h5>
                                                </header>
                                                <div class="content-body">    

                                                    <div class="row">
                                                        <div class="col-md-12">  
                                                            <div class="form-group">
                                                                '.$a.'
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>                        
                                            </section>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
            </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 resulttesting()
    {
        $data = Homem::getdata("SELECT * FROM `results_data` ORDER BY `resultdate` DESC");
        $crse = array();
        $yer = array();
        $sm = array();
        $subcode = array();
        $subname = array();
        $rdate = array();
        $exam_year = array();
        $exam_month = array();
        foreach ($data as $h) {
            $crse[] = $h['fk_course_id'];
            $yer[] = $h['year'];
            $sm[] = $h['sem'];
            $subcode[] = $h['result_type'];
            $rdate[] = $h['resultdate'];
            $exam_year[] = $h['examyear'];
            $exam_month[] = $h['exammonth'];
        }
        $course = array_values(array_unique($crse));
        sort($course);
        $year = array_values(array_unique($yer));
        sort($year);
        $sem = array_values(array_unique($sm));
        sort($sem);
        $resulttype = array_values(array_unique($subcode));
        sort($resulttype);
        $resultdate = array_values(array_unique($rdate));
        sort($resultdate);
        $examyear = array_values(array_unique($exam_year));
        sort($examyear);
        $exammonth = array_values(array_unique($exam_month));
        sort($exammonth);
    }
    /**
     * Student marks uploading bulk - ended
     */
    /**
     * Student Fee payment details bulk uploading by id
     */
    public static function allotstdfeebyid()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4"> 
                                <form action="/Accounts/saveallotstdfeebyid" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Fee Collection Entry by Unique ID</h5>
                                                </header>
                                                <div class="content-body">    
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">                                      
                                                                <input type="file" name="file" id="file" class="form-control" placeholder="Category Name">
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">   
                                                                <input type="hidden" name="type" id="type" class="form-control" value="bulk" placeholder="Type">                                         
                                                                <a href="/hindu/formats/stdnt_fee_collectiobyid_format.csv">Click Here to Download Uploading Format</a>
                                                            </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>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </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 saveallotstdfeebyid()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $date = date('Y-m-d');
            if($_POST['type'] == 'bulk')
            {
                $filename=$_FILES['file']['name'];
                $exts[0]='csv';
                $filetype1 = explode('.',$filename);
                if($_FILES['file']['name']!=null && $filetype1[sizeof($filetype1)-1] == $exts[0])
                {
                    $csv_file=$_FILES['file']['tmp_name'];
                    $size=$_FILES['file']['size'];
                    $handle = fopen($csv_file, "r");
                    $data = fgetcsv($handle, 100000, ",");
                    $i = 0;
                    while (($data = fgetcsv($handle, 100000, ","))!== FALSE)
                    {
                        $id = trim($data[0]);
                        $year = trim($data[1]);
                        $feetype = trim($data[2]);
                        $amount = trim($data[3]);
                        $recieptno = trim($data[4]);
                        $feemode = trim($data[5]);
                        $paid_date = trim($data[6]);
                        $paiddate =static::datemodify($paid_date);
                        if($id != '' && $amount !='')
                        {
                            $query = "INSERT INTO `stdnt_normalfee` (`nid`, `no`, `year`, `fk_feetype_id`, `amount`, `recieptno`, `fk_feemode_id`, `paid_date`, `remarks`, `fk_org_id`, `entry_date`, `entry_id`, `edit_date`, `edit_id`) VALUES (NULL, '$id', '$year', '$feetype', '$amount', '$recieptno', '$feemode', '$paiddate', '', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '', '')";
                            Homem::insert($query);
                            $i++;
                        }
                    }
                    echo '<script>window.location = "/Accounts/allotstdfeebyid?status=1&count='.$i.'";</script>';
                }
            }
        }
    }
    /* Modify date started*/
    public static function dtest() // testing for date conversion
    {
        $date = '34/35/36';
        echo static::datemodify($date);
    }
    private static function datemodify($date)
    {
        $ar = static::datesplit($date);
        if(is_array($ar))
        {
            return static::datesort($ar);
        }
    }
    private static function datesplit($date)
    {
        if(isset($date))
        {
            $d = explode("-", $date);
            if(is_array($d))
            {
                if(sizeof($d) == 3)
                {
                    return $d;
                }
                else
                {
                    $e = explode("/", $date);
                    if(is_array($e))
                    {
                        if(sizeof($e) == 3)
                        {
                            return $e;
                        }
                        else
                        {
                            $f = explode(".", $date);
                            if(is_array($f))
                            {
                                if(sizeof($f) == 3)
                                {
                                    return $f;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    private static function datesort($a)
    {
        if(strlen($a[0]) == 4)
        {
            return $a[0].'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[2]);
        }
        if(strlen($a[2]) == 4)
        {
            return $a[2].'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[0]);
        }
        if(strlen($a[2]) <= 2 && strlen($a[1]) <= 2 && strlen($a[0]) <= 2)
        {
            return static::apendyearfront($a[2]).'-'.static::appendzeromonth($a[1]).'-'.static::appendzerodate($a[0]);
        }
    }
    private static function appendzeromonth($m)
    {
        if($m >=1 && $m <=12)
        {
            if(strlen($m) == 2)
            {
                return $m;
            }
            else
            {
                return '0'.$m;
            }
        }
        else
        {
            return '01';
        }
    }
    private static function appendzerodate($m)
    {
        if($m >=1 && $m <=31)
        {
            if(strlen($m) == 2)
            {
                return $m;
            }
            else
            {
                return '0'.$m;
            }
        }
        else
        {
            return '01';
        }
    }
    private static function apendyearfront($a)
    {
        if(strlen($a) == 2)
        {
            if(date('y') >=$a)
            {
                return '20'.$a;
            }
            else
            {
                return date('Y');
            }
        }
    }
    /* Modify date 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 */

    /**Default functions to support the main functions starting*/
    private static function year()
    {
        $year = date('Y')+5;
        $a = '';
        for($i=0; $i<=40; $i++)
        {
            $y = $year-$i;
            $a .= '<option value="'.$y.'">'.$y.'</option>';
        }
        return $a;
    }
    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 PROCESSING';
                }
                if($id == 28)
                {
                    return 'HORTICULTURAL LANDSCAPING';
                }
                if($id == 29)
                {
                    return 'General (Un-aided)';
                }
            }
            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 Engineering';
                }
                else if($id == 2)
                {
                    return 'Electrical & Electronics Engineering';
                }
                else if($id == 3)
                {
                    return 'Mechanical Engineering';
                }
                else if($id == 4)
                {
                    return 'Electronics & Communication Engineering';
                }
                else if($id == 5)
                {
                    return 'Computer Science Engineering';
                }
                else if($id == 6)
                {
                    return 'Wed Design';
                }
                else if($id == 8)
                {
                    return 'AI&ML';
                }
                else
                {
                    return '';
                }
            }
            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 'HOSPITAL MANAGEMENT';
                }
            }
            if($_SESSION['org_id'] == 6)
            {
                if($id == 1)
                {
                    return 'M.Com';
                }
            }
        }
    }
    private static function feetype($id)
    {
        if($id != '')
        {
            if($_SESSION['org_id'] == 1)
            {
                if($id == 1)
                {
                    return 'Andhra Bank<br> Tution Fee';
                }
                if($id == 2)
                {
                    return 'Baroda Bank<br> Tution Fee';
                }
            }
            else if($_SESSION['org_id'] == 5)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Service 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;
    }
    private static function squota($id, $course)
    {
        if($id != '')
        {
            if($id == 'M' && $course==1)
            {
                return 'SPOT Admission';
            }
            if($id == 'M' && $course==2)
            {
                return 'Management Quota';
            }
            if($id == 'C' && ($course==1 || $course==2))
            {
                return 'Convenor Quota';
            }
            if($id == 'S')
            {
                return 'Spot Admission';
            }
        }
    }
    private static function nyear($id)
    {
        if($id != '')
        {
            if($id == 1)
            {
                return 'First Year';
            }
            if($id == 2)
            {
                return 'Second Year';
            }
            if($id == 3)
            {
                return 'Third Year';
            }
            if($id == 4)
            {
                return 'Fourth Year';
            }
            if($id == 5)
            {
                return 'Fifth Year';
            }
        }
    }
    public static function numtotext($number)
    {
        $decimal = round($number - ($no = floor($number)), 2) * 100;
        $hundred = null;
        $digits_length = strlen($no);
        $i = 0;
        $str = array();
        $words = array(0 => '', 1 => 'One', 2 => 'Two',
            3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'Six',
            7 => 'Seven', 8 => 'Eight', 9 => 'Nine',
            10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve',
            13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen',
            16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen',
            19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty',
            40 => 'Forty', 50 => 'Fifty', 60 => 'Sixty',
            70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety');
        $digits = array('', 'Hundred','Thousand','Lakh', 'Crore');
        while( $i < $digits_length ) {
            $divider = ($i == 2) ? 10 : 100;
            $number = floor($no % $divider);
            $no = floor($no / $divider);
            $i += $divider == 10 ? 1 : 2;
            if ($number) {
                $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
                $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
                $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
            } else $str[] = null;
        }
        $Rupees = implode('', array_reverse($str));
        $paise = ($decimal > 0) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';
        return ($Rupees ? $Rupees . 'Rupees Only' : '') . $paise;
    }
    /**Default functions to support the main functions ending*/

    /** Before login menu work start */
    public static function latest()
    {
        $data = Homem::getdata("SELECT * FROM `latest_news` WHERE `status`='1' ORDER BY id asc");
        $tdata = '';
        if(sizeof($data) > 0)
        {
            for($i=0; $i < sizeof($data); $i++)
            {
                $j=$i+1;
                $tdata .= '<tr><td>'.$j.'</td><td>'.$data[$i]['description'].'</td><td>'.$data[$i]['edate'].'</td></tr>';
            }
        }
        echo static::css();
        echo '<body>';
        echo static::normalmenu();
        echo '
        <div class="clearfix"></div>
		<form action="Search.php" method="POST">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-2"></div>
                    <div class="col-md-8">                                       
                        <div class="row">
                            <div class="col-md-12">
                                <section class="box" style="margin-top: 30px;">
                                    <header class="panel_header">
                                        <h2 class="title pull-left">LATEST NEWS / INFORMATION</h2>
                                        <div class="actions panel_actions pull-right">
                                            <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="table-responsive">													
                                                    <table class="table table-bordered">
                                                        <thead>
                                                        <tr>
                                                            <th>S. No.</th>
                                                            <th>Description</th>
                                                            <th>Date</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>';
                                                        echo $tdata;
                                                        
                                                echo '</tbody>
                                                    </table>
                                                </div>
                                                </div>
                                            </div>
                                            
                                    </div>  
                                </section>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-2"></div>
                </div>
            </div>
        </form>
        ';
        echo '</body>';
        echo static::script();
    }
    public static function suggestions()
    {
        echo static::css();
        echo '<body>';
        echo static::normalmenu();
        echo '
        <div class="clearfix"></div>
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-1"></div>
                <div class="col-lg-10">                                       
                    <div class="row">
                        <div class="col-md-12">
                            <section class="box" style="margin-top: 30px;">
                                <header class="panel_header">
                                    <h2 class="title pull-left">Suggest Us Here</h2>
                                    <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">
									<form action="savesuggestions" method="POST">	
											<div class="row">
												<div class="col-md-12">  
													<div class="form-group">
														Your Suggestions are most valuble in improving our services.
													</div>
												</div>
											</div>
											<div class="row">
												<div class="col-md-12">
													<div class="row">
														<div class="col-md-6">
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="name" class="form-control" placeholder="Name" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="email" class="form-control" placeholder="Email" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="mobile" class="form-control" placeholder="Mobile" required />
																	</div>
																</div>  
															</div>													
														</div>
														<div class="col-md-6">
															<div class="form-group">							
																<textarea name="Suggestions" id="Suggestions" type="text" class="form-control" placeholder="Enter your Suggestions here..." style="height:138px;resize:none;" required /></textarea>
															</div>
														</div>  
													</div>											
												</div>
											</div>										
											<div class="row">
												<div class="col-md-12">  
													<div class="form-group">
														<label id="lbl_msg" class="label label-primary pull-left"></label>
														<button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
														<div id="spinner1" class="pull-right circle-loader ">
															<div class="checkmark draw"></div>
														</div>
													</div>
												</div>
											</div>										

									</form>
                                </div>                        
                            </section>
                        </div>
                    </div>
                </div>
                <div class="col-lg-1"></div>
            </div>
        </div>
        ';
        echo '</body>';
        echo static::script();
        if(isset($_GET['status']))
        {
            if($_GET['status'] == 1)
            {
                echo '<script>swal("Submitted Successfully", "We will contact you regarding your query..", "success");</script>';
            }
            else
            {
                echo '<script>swal("Something Went Wrong..", "Please Tryagain Later", "error");</script>';
            }
        }
    }
    public static function savesuggestions()
    {
        if($_POST['name'] != '' && $_POST['email'] != '' && $_POST['mobile'] != '')
        {
            date_default_timezone_set('Asia/Kolkata'); 
            $today_time =  date('d-m-Y h:i:s A');
            $status = Homem::insert("INSERT INTO `suggestions` (`id`, `name`, `email`, `mobile`, `suggestions`, `endate`, `status`) VALUES ('', '$_POST[name]', '$_POST[email]', '$_POST[mobile]', '$_POST[Suggestions]', '$today_time', '1')");
            echo '<script>window.location="/Accounts/suggestions?status=1";</script>';
        }
        else
        {
            echo '<script>window.location="/Accounts/suggestions?status=0";</script>';
        }
    }
    public static function contactus()
    {
        echo static::css();
        echo '<body>';
        echo static::normalmenu();
        echo '
        <div class="clearfix"></div>
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">                                       
                    <div class="row">
                        <div class="col-lg-1"> </div>  
                        <div class="col-md-10">
                            <section class="box" style="margin-top: 30px;">
                                <header class="panel_header">
                                    <h2 class="title pull-left">Contact Us</h2>
                                    <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">
									<form action="/Accounts/savecontactus" method="POST">	
											<div class="row">
                                                
												<div class="col-md-12">
													<div class="row">
														<div class="col-md-3">
														</div>
														<div class="col-md-6">
															<div class="row">
																<div class="col-md-12">  
																	<div class="form-group">
																		For Any Other Queries:
																	</div>
																</div>
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="name" class="form-control" placeholder="Name" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="email" class="form-control" placeholder="Email" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="mobile" class="form-control" placeholder="Mobile" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group"> 
																		<input type="text" name="subject" class="form-control" placeholder="Subject" required />
																	</div>
																</div>  
															</div>
															<div class="row">
																<div class="col-md-12">
																	<div class="form-group">							
																		<textarea name="message" id="Suggestions" type="text" class="form-control" placeholder="Message" style="height:138px;resize:none;" required /></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>  
                                                        <div class="col-md-3">
														</div>
													</div>											
												</div>
                                               
											</div>										
									</form>
                                </div>                        
                            </section>
                        </div>
                        <div class="col-lg-1"> </div>  
                    </div>
                </div>
            </div>
        </div>
        ';
        echo '</body>';
        echo static::script();
        if(isset($_GET['status']))
        {
            if($_GET['status'] == 1)
            {
                echo '<script>swal("Submitted Successfully", "We will contact you regarding your query..", "success");</script>';
            }
            else
            {
                echo '<script>swal("Something Went Wrong..", "Please Tryagain Later", "error");</script>';
            }
        }
    }
    public static function savecontactus()
    {
        if($_POST['name'] != '' && $_POST['email'] != '' && $_POST['mobile'] != '')
        {
            date_default_timezone_set('Asia/Kolkata'); 
            $today_time =  date('d-m-Y h:i:s A');
            $status = Homem::insert("INSERT INTO `contactus`(`name`, `email`, `mobile`, `subject`, `message`, `edate`, `status`)  VALUES ('$_POST[name]', '$_POST[email]', '$_POST[mobile]', '$_POST[subject]','$_POST[message]', '$today_time', '1')");
            echo '<script>window.location="/Accounts/contactus?status=1";</script>';
        }
        else
        {
            echo '<script>window.location="/Accounts/contactus?status=0";</script>';
        }
    }
    /** Before login menu work end */
    /** Strting of Login Screen  and Authentication */
    private static function normalmenu()
    {
        // bg-light
        $menu = '
            <nav class="navbar navbar-expand-lg navbar-light ">
                <a class="navbar-brand" href="#" >HINDU COLLEGE</a>
                <button style="background-color:white;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ml-auto navbar-right">
                    
                    <li class="nav-item active" >
                        <a class="nav-link" href="/Accounts/index" >Home</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/latest" >Latest News</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/suggestions" >Suggestions</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/contactus" >Contact Us</a>
                    </li>
                    <!--
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        Dropdown
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="#">Action</a>
                        <a class="dropdown-item" href="#">Another action</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="#">Something else here</a>
                        </div>
                    </li>
                    -->
                    </ul>
                    <form class="form-inline my-2 my-lg-0">
                    <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
                    <button class="btn btn-outline-light my-2 my-sm-0" type="submit">Search</button>
                    </form>
                </div>
            </nav>
        ';
        return $menu;
    }
    public static function index()
    {
        echo static::css();
        echo '<body>';
        echo static::normalmenu();
        if(static::checkbrower() == 1)
        {
            echo '
                <div class="container">
                        <div class="container-fluid">
                            <div class="row" style="margin-top:20px;">
                                <div class="col-xl-4"></div>
                                <div class="col-xl-4">
                                <div class="card">
                                    <div class="card-body">
                                        <form action="/Accounts/accountsauth" method="POST" enctype="multipart/form-data">
                                            <div class="form-group">
                                                <div class="float-center">Login Here</div>
                                            </div>
                                            <div class="form-group">
                                                <select class="form-control" name="orgname" id="orgname" required>
                                                    <option value="">Select College</option>
                                                    <option value="1">Hindu College - Main Campus (Unaided)</option>
                                                    <option value="2">Hindu College (UG & PG Courses)- Amaravathi Road Campus</option>
                                                    <option value="3">Hindu College of Engineering & Technology</option>
                                                    <option value="4">Hindu College -MCA</option>
                                                    <option value="5">Hindu College of Management</option>
                                                    <!--
                                                    <option value="6">Hindu College - M.Com</option>-->
                                                </select>
                                            </div>
                                            <div class="form-group">
                                                <input type="text" class="form-control" name="username" id="username" placeholder="User Name" required>
                                            </div>
                                            <div class="form-group">
                                                <input type="password" class="form-control" name="password" id="password" placeholder="Password" required>
                                            </div>
                                            <div class="form-group">
                                                <div class="float-right">
                                                    <input type="submit" class="btn btn-primary" style="background-color: #002366 !important;" value="Submit">
                                                </div>
                                                
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                </div>
                                <div class="col-xl-4"></div>
                            </div>
                        </div>
                    </div>
                ';
        }
        else
        {
                echo '
                <div class="container">
                        <div class="container-fluid">
                            <div class="row" style="margin-top:20px;">
                                <div class="col-xl-4"></div>
                                <div class="col-xl-4">
                                <div class="card">
                                    <div class="card-body">
                                        <form action="/Accounts/auth" method="POST" enctype="multipart/form-data">
                                            <div class="form-group">
                                                <div class="float-right">
                                                    <a>Please use Google Chrome / Microsoft Edge Browser for Best user Experience.</a>
                                                </div> 
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                </div>
                                <div class="col-xl-4"></div>
                            </div>
                        </div>
                    </div>
                ';
        }
        echo '</body>';
        echo static::script();
    }
    private static function usermenu()
    {
        $menu = '
            <nav class="navbar navbar-expand-lg navbar-light " style="background-color: #002366; text-color: #ffffff;">
                <a class="navbar-brand" href="#" style="color: #ffffff;">HINDU COLLEGE</a>
                <button style="background-color:white;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ml-auto navbar-right">
                    <li class="nav-item active">
                        <a class="nav-link" href="/Main/home" >Home</a>
                    </li>
                <!--
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Masters
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/bloodgroup" >Blood Group</a>
                        <a class="dropdown-item" href="/Main/courses">Courses</a>
                        <a class="dropdown-item" href="/Main/departments">Departments</a>
                        <a class="dropdown-item" href="/Main/category">Category</a>
                        </div>
                    </li>
                    
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Students
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/supload" >Upload Student Details</a>
                        <a class="dropdown-item" href="/Main/slist" >View List of Students</a>
                        <a class="dropdown-item" href="/Main/addstudent">Individual Student Entry</a>
                        <a class="dropdown-item" href="/Main/ssearch" >Search a Student</a>
                        <a class="dropdown-item" href="/Main/upstdntphotos">Upload Students Photos</a>
                        <a class="dropdown-item" href="/Main/stdntadditional">Student Additional Details</a>
                        </div>
                    </li>
                    
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        User
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/ulist">View List of Users</a>
                        <a class="dropdown-item" href="/Main/adduser">Individual User Entry</a>
                        </div>
                    </li>
                    
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Subject
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/searchsub">Search Subjects Available</a>
                        <a class="dropdown-item" href="/Main/indsubject">Individual Subject Entry</a>
                        <a class="dropdown-item" href="/Main/bulksubject">Bulk Subject Uploading</a>
                        </div>
                    </li>
                
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Marks Entry
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/uploadmarks" >B.Tech Marks Entry</a>
                        <a class="dropdown-item" href="/Main/mdipinformat">Diploma Marks (College Format)</a>
                        <a class="dropdown-item" href="/Main/mindividual" >Individual Marks Entry</a>
                        <a class="dropdown-item" href="/Main/editindstdmarks"  >Edit Individual Student Marks</a>
                        </div>
                    </li>
                    -->
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Reports 
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/studentresultfinal" >Student Result</a>
                        <!--<a class="dropdown-item" href="/Main/sattempts" >Student Attempts</a>-->
                        <a class="dropdown-item" href="/Main/semwiseconmarks" >Sem wise Consolidated Marks Report</a>
                        <a class="dropdown-item" href="/Main/sbacklogs" >Sem Wise Student Backlogs</a>
                        <a class="dropdown-item" href="/Main/subwisefailistinsem" >Subject wise Baclogs in Sem</a>
                        <a class="dropdown-item" href="/Main/subwiseresults" >Subject Wise Results</a>
                        <a class="dropdown-item" href="/Main/deptwiseresult" >Semester Wise Result Analysis</a>
                        </div>
                    </li>
                <!--
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Fee 
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Main/allotstdfee" >Allot Fee for Students</a>
                        <a class="dropdown-item" href="/Main/normalfeecolect" >Normal Fee Collection</a>
                        <a class="dropdown-item" href="/Main/examfeecollect" >Exam Fee Collection</a>
                        <a class="dropdown-item" href="/Main/stdntindfee" >Check Student Fees</a>
                        </div>
                    </li>
                -->
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        '.$_SESSION['name'].'
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/logout" >Logout</a>
                        </div>
                    </li>
                    </ul>
                </div>
            </nav>
        ';
        return $menu;
    }
    public static function accountsauth()
    {
        if($_POST['username'] != '' && $_POST['password'] != '')
        {
            $_SESSION['org_id'] = $_POST['orgname'];
            $qurey = "SELECT * FROM `user_master` WHERE (`no` = '$_POST[username]' OR `mobile` = '$_POST[username]' OR `email` = '$_POST[username]') AND `password`='$_POST[password]' AND status='1'";
            $data = Homem::getdata($qurey);
            if(sizeof($data) == 1)
            {
                $_SESSION['user_id'] = $data[0]['id'];
                $_SESSION['user_no'] = $data[0]['no'];
                $_SESSION['name'] = $data[0]['name'];
                $_SESSION['org_id'] = $data[0]['org_id'];
                $_SESSION['mobile'] = $data[0]['mobile'];
                $_SESSION['email'] = $data[0]['email'];
                $_SESSION['user_role'] = $data[0]['user_role'];
                if($data[0]['user_role'] == 4)
                {
                    $_SESSION['menu'] = static::accountsmainmenu();
                }
                if($data[0]['user_role'] == 5)
                {
                    $_SESSION['menu'] = static::collectionmainmenu();
                }
                if($data[0]['user_role'] == 6)
                {
                    $_SESSION['menu'] = static::adminmainmenu();
                }
                if($data[0]['user_role'] == 9)
                {
                    $_SESSION['menu'] = static::usermenu();
                }
                echo '<script>window.location="/Accounts/home";</script>';
            }
            else
            {
                echo '<script>window.location="/Accounts/index?status=0";</script>';
            }
        }
        else
        {
            echo '<script>window.location="/Accounts/index?status=0";</script>';
        }
            
    }
    private static function accountsmainmenu()
    {
        $menu = '
            <nav class="navbar navbar-expand-lg navbar-light " style="background-color: #002366; text-color: #ffffff;">
                <a class="navbar-brand" href="#" style="color: #ffffff;">HINDU COLLEGE</a>
                <button style="background-color:white;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ml-auto navbar-right">
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/home" >Home</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/normalfeecolect" >Old Fee Reciept</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/normalfeecolectnew">New Fee Collection</a>
                    </li>
                    <li class="nav-item active">
                    <a class="nav-link" href="/Accounts/hnowiseconsreport" >Individual Student Fee Report</a>
                    </li>
                    
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Fee Collection Reports
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/slist" >List of Students</a>
                        <a class="dropdown-item" href="/Accounts/deptwisefeesettingreport" >Department wise Fee List</a>
                        <a class="dropdown-item" href="/Accounts/deptwiseconsol" >Dept Wise Consolidated Report</a>
                        <a class="dropdown-item" href="/Accounts/coursewiseconsol" >Course Wise Detailed Report</a>
                        <a class="dropdown-item" href="/Accounts/datewisecon" >Date wise fee collection report</a>
                        <a class="dropdown-item" href="/Accounts/reportbwndates" >Fee Collection betwen two dates</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        '.$_SESSION['name'].'
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/logout" >Logout</a>
                        </div>
                    </li>
                    </ul>
                </div>
            </nav>
        ';
        return $menu;
    }
    private static function collectionmainmenu()
    {
        $menu = '
            <nav class="navbar navbar-expand-lg navbar-light " style="background-color: #002366; text-color: #ffffff;">
                <a class="navbar-brand" href="#" style="color: #ffffff;">HINDU COLLEGE</a>
                <button style="background-color:white;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="navbar-nav ml-auto navbar-right">
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/home" >Home</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/normalfeecolect" >Old Fee Reciept</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/normalfeecolectnew">New Fee Collection</a>
                    </li>
                    <li class="nav-item active">
                    <a class="nav-link" href="/Accounts/hnowiseconsreport" >Individual Student Fee Report</a>
                    </li>
                    
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Fee Collection Reports
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/slist" >List of Students</a>
                        <a class="dropdown-item" href="/Accounts/deptwisefeesettingreport" >Department wise Fee List</a>
                        <a class="dropdown-item" href="/Accounts/deptwiseconsolactive" >Dept Wise Consolidated Report</a>
                        <a class="dropdown-item" href="/Accounts/coursewiseconsolactive" >Course Wise Detailed Report</a>
                        <a class="dropdown-item" href="/Accounts/datewisecon" >Date wise fee collection report</a>
                        <a class="dropdown-item" href="/Accounts/reportbwndates" >Fee Collection betwen two dates</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Add New Data
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/addstudent" >Add Student</a>
                        <a class="dropdown-item" href="/Accounts/allotindstdfee" >Add Individual Student Prescribed Fee</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        '.$_SESSION['name'].'
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/logout" >Logout</a>
                        </div>
                    </li>
                    </ul>
                </div>
            </nav>
        ';
        return $menu;
    }
    private static function adminmainmenu()
    {
        $menu = '
            <nav class="navbar navbar-expand-lg navbar-light " style="background-color: #002366; text-color: #ffffff;">
                <a class="navbar-brand" href="#" style="color: #ffffff;">HINDU COLLEGE</a>
                <button style="background-color:white;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav ml-auto navbar-right">
                        <li class="nav-item active">
                            <a class="nav-link" href="/Accounts/home" >Home</a>
                        </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/Accounts/normalfeecolectnew">New Fee Collection</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Total
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/deptwiseconsol" >Dept Wise Consolidated Report</a>
                        <a class="dropdown-item" href="/Accounts/coursewiseconsol" >Course Wise Detailed Report</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Active
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/deptwiseconsolactive" >Dept Wise Consolidated Report</a>
                        <a class="dropdown-item" href="/Accounts/coursewiseconsolactive" >Course Wise Detailed Report</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Discontinued
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/deptwiseconsolinactive" >Dept Wise Consolidated Report</a>
                        <a class="dropdown-item" href="/Accounts/coursewiseconsolinactive" >Course Wise Detailed Report</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Accounts Section
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/allotstdfee" >Bulk Uploading of Student Fee</a>
                        <a class="dropdown-item" href="/Accounts/allotindstdfee" >Individual Fee Upload</a>
                        <a class="dropdown-item" href="/Accounts/normalfeeconcession" >Concession Fee Details</a>
                        <a class="dropdown-item" href="/Accounts/deptwisefeesettingreport" >Department wise Fee List</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="/Accounts/normalfeecolect" >Normal Fee Collection</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="/Accounts/hnowiseconsreport" >Individual Student Fee Report</a>
                        
                        <a class="dropdown-item" href="/Accounts/dailyreport" >Operator Entry Report Date Wise</a>
                        <a class="dropdown-item" href="/Accounts/datewisecon" >Date wise Fee Collection</a>
                        <a class="dropdown-item" href="/Accounts/reportbwndates" >Fee Collection Between Two Dates</a>
                        <a class="dropdown-item" href="/Accounts/reportbybook" >Book Wise Fee Reciept Details</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="/Accounts/admcmpforfuryer" >Admission Comparison for Four Years (MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractbyayyear" >Overall Abstract for Academic Year (MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractforallcurses" >Overall Abstract for All Courses (MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractdueinacy" >Overall Abstract for Dues in Academic year (MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractdueinacylinks" >Detailed Overall Abstract for Dues in Academic year (MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractduebydiscotnuesinacylinks" >Detailed Overall Abstract for Dues of transfer and discontinued(MIS)</a>
                        <a class="dropdown-item" href="/Accounts/ovabstractduebyexcludeddiscotnuesinacylinks" >Detailed Overall Abstract for Dues excluding transfer and discontinued(MIS)</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        Extra
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Exams/stdntdetails" >Student Details</a>
                        <a class="dropdown-item" href="/Exams/userdetails" >User Details</a>
                        </div>
                    </li>';
                $menu .='<li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                    Results 
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                    <a class="dropdown-item" href="/Main/studentresultfinal" >Student Result</a>
                    <!--<a class="dropdown-item" href="/Main/sattempts" >Student Attempts</a>-->
                    <a class="dropdown-item" href="/Main/semwiseconmarks" >Sem wise Consolidated Marks Report</a>
                    <a class="dropdown-item" href="/Main/sbacklogs" >Sem Wise Student Backlogs</a>
                    <a class="dropdown-item" href="/Main/subwisefailistinsem" >Subject wise Baclogs in Sem</a>
                    <a class="dropdown-item" href="/Main/subwiseresults" >Subject Wise Results</a>
                    <a class="dropdown-item" href="/Main/deptwiseresult" >Semester Wise Result Analysis</a>
                    </div>
                </li>';
                $menu .='<li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >
                        '.$_SESSION['name'].'
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown" style="background-color: #002366;">
                        <a class="dropdown-item" href="/Accounts/logout" >Logout</a>
                        </div>
                    </li>
                    </ul>
                </div>
            </nav>
        ';
        return $menu;
    }
    public static function home()
    {
        if($_SESSION['user_role'] != '')
        {
            echo static::css();
            echo '<body>';
                echo $_SESSION['menu'];
                echo '
                <div class="container">
                    <div class="container-fluid">
                        <div class="row" style="margin-top:20px;">
                            <div class="col-xl-12">
                            <!--Welcome to HINDU COLLEGE-->
                            </div>
                        </div>
                    </div>
                </div>
                ';
            echo '</body>';
            echo static::script();
        }
    }
    public static function userorgchange()
    {
        if($_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            if(static::checkbrower() == 1)
            {
                echo '
                    <div class="container">
                            <div class="container-fluid">
                                <div class="row" style="margin-top:20px;">
                                    <div class="col-xl-4"></div>
                                    <div class="col-xl-4">
                                    <div class="card">
                                        <div class="card-body">
                                            <form action="" method="POST" enctype="multipart/form-data">
                                                <div class="form-group">
                                                    <div class="float-center">Please Select Institution here</div>
                                                </div>
                                                <div class="form-group">
                                                    <select class="form-control" name="orgname" id="orgname" onchange="changeuserorgid()" required>
                                                        <option value="">Select College</option>
                                                        <option value="1">Hindu College - Main Campus (Unaided)</option>
                                                        <option value="2">Hindu College (UG & PG Courses)- Amaravathi Road Campus</option>
                                                        <option value="3">Hindu College of Engineering & Technology</option>
                                                        <option value="4">Hindu College -MCA</option>
                                                        <option value="5">Hindu College of Management</option>
                                                        <option value="6">Hindu College - M.Com</option>
                                                    </select>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                    </div>
                                    <div class="col-xl-4"></div>
                                </div>
                            </div>
                        </div>
                    ';
            }
            echo '</body>';
            echo static::script();
            echo '
                <script>
                    setTimeout(function(){ 
                        $("#orgname").val("'.$_SESSION['org_id'].'");
                    }, 1000);
                    function changeuserorgid()
                    {
                        var orgid = $("#orgname").val();
                        $.ajax({
                            url: "/Accounts/changeuserorgid",
                            type: "post",
                            data: {orgid: orgid},
                            success: function(d) {
                                if(d == "success")
                                {
                                    swal("Successfull..", "You can view reports of the selected organization now..", "success");
                                    setTimeout(function(){ 
                                        location.reload();
                                    }, 3000);
                                }
                            }
                        });
                    }
                </script>
            ';
        }
    }
    public static function changeuserorgid()
    {
        if($_SESSION['user_role'] == 6)
        {
            if(isset($_POST['orgid']))
            {
                if($_POST['orgid'] != '') 
                {
                    $_SESSION['org_id'] = $_POST['orgid'];
                    echo 'success';
                }
            }
        }
    }
    public static function logout()
    {
        $_SESSION['user_role'] = '';
        unset($_SESSION['user_id']);
        unset($_SESSION['user_no']);
        unset($_SESSION['name']);
        unset($_SESSION['org_id']);
        unset($_SESSION['mobile']);
        unset($_SESSION['email']);
        unset($_SESSION['user_role']);
        session_unset();
        session_destroy();
        echo '<script>window.location="/Accounts/index";</script>';
    }
    /** Ending of Login Screen and Authentication */

    /* Start of master section */
    public static function bloodgroup()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            if(isset($_GET['deleteid']))
            {
                Homem::insert("DELETE FROM `blood_group` WHERE `id`='$_GET[deleteid]'");
            }
            $blood = Homem::getdata("SELECT * FROM `blood_group`");
            $table = Form::dbtableed($blood, ['S. No.', 'Blood Group'], ['id', 'name'], '/Accounts/bloodgroup', 'id', 'id');
            echo static::css();
            echo '<body>';
                echo $_SESSION['menu'];
                echo '
                <div class="clearfix"></div>
                <form action="/Accounts/savebloodgroup" method="POST">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-2"></div>
                        <div class="col-lg-4">                                       
                            <div class="row">
                                <div class="col-lg-12">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">ADD NEW BLOOD GROUP</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-12">
                                                    <div class="form-group">                                      
                                                        <input type="text" name="group" id="group" class="form-control" placeholder="Blood Group">
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">                                            
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="editid">
                                                    </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-1"></div>
                        <div class="col-lg-5">
                        ';
                        echo $table;
                        echo '
                        </div>
                    </div>
                </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['editid']))
            {
                for($i=0; $i<sizeof($blood); $i++)
                {
                    if($blood[$i]['id'] == $_GET['editid'])
                    {
                        echo '
                        <script>
                            $("#group").val("'.$blood[$i]['name'].'");
                            $("#edit_id").val("'.$blood[$i]['id'].'");
                        </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 savebloodgroup()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            if($_POST['edit_id'] != '')
            {
                Homem::insert("UPDATE `blood_group` SET `name`='$_POST[group]' WHERE `id`='$_POST[edit_id]'");
            }
            else
            {
                Homem::insert("INSERT INTO `blood_group`(`name`) VALUES ('$_POST[group]')");
            }
            echo '<script>window.location = "/Accounts/bloodgroup?status=1";</script>';
        }
    }
    public static function courses()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            $blood = Homem::getdata("SELECT * FROM `degree_name_master`");
            $table = Form::dbtableed($blood, ['S. No.', 'Code', 'Name'], ['id', 'code', 'name'], '/Accounts/courses', 'id', '');
            echo static::css();
            echo '<body>';
                echo $_SESSION['menu'];
                echo '
                <div class="clearfix"></div>
                <form action="/Accounts/savecourses" method="POST">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-2"></div>
                        <div class="col-lg-4">                                       
                            <div class="row">
                                <div class="col-lg-12">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">ADD NEW COURSE</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-12">
                                                    <div class="form-group">                                      
                                                        <input type="text" name="code" id="code" class="form-control" placeholder="Courses Code">
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">                                      
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Course Name">
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">                                            
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="editid">
                                                    </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-5">
                        ';
                        echo $table;
                        echo '
                        </div>
                        <div class="col-lg-1"></div>
                    </div>
                </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['editid']))
            {
                for($i=0; $i<sizeof($blood); $i++)
                {
                    if($blood[$i]['id'] == $_GET['editid'])
                    {
                        echo '
                        <script>
                            $("#code").val("'.$blood[$i]['code'].'");
                            $("#name").val("'.$blood[$i]['name'].'");
                            $("#edit_id").val("'.$blood[$i]['id'].'");
                        </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 savecourses()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            if($_POST['edit_id'] != '')
            {
                Homem::insert("UPDATE `degree_name_master` SET `code`='$_POST[code]', `name`='$_POST[name]' WHERE `id`='$_POST[edit_id]'");
            }
            else
            {
                Homem::insert("INSERT INTO `degree_name_master`(`code`, `name`) VALUES ('$_POST[code]', '$_POST[name]')");
            }
            echo '<script>window.location = "/Accounts/courses?status=1";</script>';
        }
    }
    public static function departments()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            $blood = Homem::getdata("SELECT * FROM `degree_dept_master`");
            $table = Form::dbtableed($blood, ['S. No.', 'Name'], ['id', 'name'], '/Accounts/departments', 'id', '');
            echo static::css();
            echo '<body>';
                echo $_SESSION['menu'];
                echo '
                <div class="clearfix"></div>
                <form action="/Accounts/savedepartments" method="POST">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-2"></div>
                        <div class="col-lg-4">                                       
                            <div class="row">
                                <div class="col-lg-12">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">ADD NEW DEPARTMENT</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-12">
                                                    <div class="form-group">                                      
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Department Name">
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">                                            
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="editid">
                                                    </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-5">
                        ';
                        echo $table;
                        echo '
                        </div>
                        <div class="col-lg-1"></div>
                    </div>
                </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['editid']))
            {
                for($i=0; $i<sizeof($blood); $i++)
                {
                    if($blood[$i]['id'] == $_GET['editid'])
                    {
                        echo '
                        <script>
                            $("#name").val("'.$blood[$i]['name'].'");
                            $("#edit_id").val("'.$blood[$i]['id'].'");
                        </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 savedepartments()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            if($_POST['edit_id'] != '')
            {
                Homem::insert("UPDATE `degree_dept_master` SET `name`='$_POST[name]' WHERE `id`='$_POST[edit_id]'");
            }
            else
            {
                Homem::insert("INSERT INTO `degree_dept_master`(`name`) VALUES ('$_POST[name]')");
            }
            echo '<script>window.location = "/Accounts/departments?status=1";</script>';
        }
    }
    public static function category()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            $blood = Homem::getdata("SELECT * FROM `category`");
            $table = Form::dbtableed($blood, ['S. No.', 'Name'], ['id', 'name'], '/Accounts/category', 'id', '');
            echo static::css();
            echo '<body>';
                echo $_SESSION['menu'];
                echo '
                <div class="clearfix"></div>
                <form action="/Accounts/savecategory" method="POST">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-2"></div>
                        <div class="col-lg-4">                                       
                            <div class="row">
                                <div class="col-lg-12">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">ADD NEW CATEGORY</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-12">
                                                    <div class="form-group">                                      
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Category Name">
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">                                            
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="editid">
                                                    </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-5">
                        ';
                        echo $table;
                        echo '
                        </div>
                        <div class="col-lg-1"></div>
                    </div>
                </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['editid']))
            {
                for($i=0; $i<sizeof($blood); $i++)
                {
                    if($blood[$i]['id'] == $_GET['editid'])
                    {
                        echo '
                        <script>
                            $("#name").val("'.$blood[$i]['name'].'");
                            $("#edit_id").val("'.$blood[$i]['id'].'");
                        </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 savecategory()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            if($_POST['edit_id'] != '')
            {
                Homem::insert("UPDATE `category` SET `name`='$_POST[name]' WHERE `id`='$_POST[edit_id]'");
            }
            else
            {
                Homem::insert("INSERT INTO `category`(`name`) VALUES ('$_POST[name]')");
            }
            echo '<script>window.location = "/Accounts/category?status=1";</script>';
        }
    }
    /* end of master section */

    /* start of fee Setting section */
    public static function allotstdfee()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4"> 
                                <form action="/Accounts/saveallotstdfee" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Fee Setting Entry</h5>
                                                </header>
                                                <div class="content-body">    
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">                                      
                                                                <input type="file" name="file" id="file" class="form-control" placeholder="Category Name">
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">   
                                                                <input type="hidden" name="type" id="type" class="form-control" value="bulk" placeholder="Type">                                         
                                                                <a href="/hindu/formats/stdnt_fee_format.csv">Click Here to Download Uploading Format</a>
                                                            </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>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `fid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#amount").val("'.$data[0]['feeamount'].'");
                        $("#terms").val("'.$data[0]['terms'].'");
                        $("#edit_id").val("'.$data[0]['fid'].'");
                    </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 allotindstdfee()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Accounts/saveallotstdfee" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Fee Setting Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()" required>      
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="Student Uniq ID" required >
                                                    </div>
                                                </div> 
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Name of the Student" readonly required>                                         
                                                    </div>
                                                </div>                             
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control" required>
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feetype" id="feetype" class="form-control" required>
                                                            <option value="">Select Fee Type</option>
                                                            '.$feetype.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="amount" id="amount" class="form-control" placeholder="Fee Amount">                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="terms" id="terms" class="form-control" placeholder="No of Terms of Payment">                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="type" id="type" class="form-control" value="single" placeholder="type">                                         
                                                    </div>
                                                </div>    
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                            getuserid();
                        }
                    });
                }
                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            // if(isset($_GET['editid']))
            // {
            //     $data = Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `fid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
            //     if(sizeof($data) == 1)
            //     {
            //         echo '
            //         <script>
            //             $("#no").val("'.$data[0]['no'].'");
            //             $("#year").val("'.$data[0]['year'].'");
            //             $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
            //             $("#amount").val("'.$data[0]['feeamount'].'");
            //             $("#terms").val("'.$data[0]['terms'].'");
            //             $("#edit_id").val("'.$data[0]['fid'].'");
            //             setTimeout(function(){ getusername(); }, 500);
            //         </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 saveallotstdfee()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $date = date('Y-m-d');
            if($_POST['type'] == 'bulk')
            {
                $filename=$_FILES['file']['name'];
                $exts[0]='csv';
                $filetype1 = explode('.',$filename);
                if($_FILES['file']['name']!=null && $filetype1[sizeof($filetype1)-1] == $exts[0])
                {
                    $csv_file=$_FILES['file']['tmp_name'];
                    $size=$_FILES['file']['size'];
                    $handle = fopen($csv_file, "r");
                    $data = fgetcsv($handle, 100000, ",");
                    $i = 0;
                    while (($data = fgetcsv($handle, 100000, ","))!== FALSE)
                    {
                        $no = trim($data[0]);
                        $year = trim($data[1]);
                        $feetype = trim($data[2]);
                        $amount = trim($data[3]);
                        $terms = trim($data[4]);
                        $udata = Homem::getdata("SELECT * FROM `user_master` WHERE `ano`='$no' OR `no`='$no'");
                        if(sizeof($udata) == 1)
                        {
                            $sid = $udata[0]['id'];
                            if(sizeof(Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `no`='$sid' AND `year`='$year' AND `fk_feetype_id`='$feetype' AND `fk_org_id`='$_SESSION[org_id]'")) > 0)
                            {
                                Homem::insert("UPDATE `stdnt_feemaster` SET `feeamount`='$amount', `reg_date`='$date', `fk_user_id`='$_SESSION[user_id]', `terms`='$terms' WHERE `no`='$sid' AND `year`='$year' AND `fk_feetype_id`='$feetype' AND `fk_org_id`='$_SESSION[org_id]'");
                                $i++;
                            }
                            else
                            {
                                Homem::insert("INSERT INTO `stdnt_feemaster` (`no`, `year`, `fk_feetype_id`, `feeamount`, `fk_org_id`, `reg_date`, `fk_user_id`, `terms`) VALUES ('$sid', '$year', '$feetype', '$amount', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '$terms')");
                                $i++;
                            }
                        }
                    }
                    echo '<script>window.location = "/Accounts/allotstdfee?status=1&count='.$i.'";</script>';
                }
            }
            if($_POST['type'] == 'single')
            {
                $no = $_POST['no'];
                $year = $_POST['year'];
                $feetype = $_POST['feetype'];
                $amount = $_POST['amount'];
                $terms = $_POST['terms'];
                $udata = Homem::getdata("SELECT * FROM `user_master` WHERE `ano`='$no' OR `no`='$no'");
                if(sizeof($udata) == 1)
                {
                    $sid = $udata[0]['id'];
                    if($sid==$_POST['sid'])
                    {
                    if($_POST['edit_id'] == '')
                    {   
                        if(sizeof(Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `no`='$sid' AND `year`='$year' AND `fk_feetype_id`='$feetype' AND `fk_org_id`='$_SESSION[org_id]'")) > 0)
                        {
                            Homem::insert("UPDATE `stdnt_feemaster` SET `feeamount`='$amount', `reg_date`='$date', `fk_user_id`='$_SESSION[user_id]', `terms`='$terms' WHERE `no`='$sid' AND `year`='$year' AND `fk_feetype_id`='$feetype' AND `fk_org_id`='$_SESSION[org_id]'");
                            echo '<script>window.location = "/Accounts/allotindstdfee?status=2";</script>';
                        }
                        else
                        {
                            Homem::insert("INSERT INTO `stdnt_feemaster` (`no`, `year`, `fk_feetype_id`, `feeamount`, `fk_org_id`, `reg_date`, `fk_user_id`, `terms`) VALUES ('$sid', '$year', '$feetype', '$amount', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '$terms')");
                            echo '<script>window.location = "/Accounts/allotindstdfee?status=1";</script>';
                        }
                    }
                    // else
                    // {
                    //     if(sizeof(Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `fid`='$_POST[edit_id]' AND `fk_org_id`='$_SESSION[org_id]'")) == 1)
                    //     {
                    //         Homem::insert("UPDATE `stdnt_feemaster` SET `no`='$sid', `year`='$year', `fk_feetype_id`='$feetype', `feeamount`='$amount', `reg_date`='$date', `fk_user_id`='$_SESSION[user_id]', `terms`='$terms' WHERE `fid`='$_POST[edit_id]' AND `fk_org_id`='$_SESSION[org_id]'");
                    //         echo '<script>window.location = "/Accounts/allotindstdfee?status=2";</script>';
                    //     }
                    // }
                    else
                    {
                        echo '<script>window.location = "/Accounts/allotindstdfee?status=0";</script>';
                    }
                    }
                }
            }
        }
    }
    public static function deptwisefeesettingreport()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $table = '';
            if(isset($_POST['course']))
            {
                $blood = Homem::getdata("SELECT * FROM user_master um JOIN stdnt_feemaster sf ON um.id=sf.no  JOIN fee_types ft ON sf.fk_feetype_id=ft.f_id WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.toyear='$_POST[toyear]' AND um.org_id='$_SESSION[org_id]' AND sf.year='$_POST[years]' AND sf.fk_feetype_id='$_POST[feetypes]'");
                $table = Form::dbtableed($blood, ['Year', 'Fee Type', 'Hallticket Number', 'Name', 'Amount'], ['year', 'f_name', 'no', 'name', 'feeamount'], '/Accounts/allotindstdfee', 'fid', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4">
                                <form action="#" method="POST">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">List by Department</h5>
                                        </header>
                                        <div class="content-body">    
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">                                            
                                                        <select name="course" id="course" class="form-control">
                                                        <option value="">Course</option>
                                                        ';
                                                        echo $course;
                                                        echo '
                                                        </select>
                                                    </div>
                                                </div>    
                                                <div class="col-lg-6">
                                                    <div class="form-group">                                            
                                                        <select name="department" id="department" class="form-control">
                                                        <option value="">Department</option>
                                                        ';
                                                        echo $dept;
                                                        echo '
                                                        </select>
                                                    </div>
                                                </div>                            
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">                                            
                                                        <select name="fromyear" id="fromyear" class="form-control">
                                                        <option value="">Starting Year</option>
                                                        ';
                                                        echo $styear;
                                                        echo '
                                                        </select>
                                                    </div>
                                                </div>  
                                                <div class="col-lg-6">
                                                    <div class="form-group">                                            
                                                        <select name="toyear" id="toyear" class="form-control">
                                                        <option value="">Ending Year</option>
                                                        ';
                                                        echo $enyear;
                                                        echo '
                                                        </select>
                                                    </div>
                                                </div>  									
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="years" id="years" class="form-control">
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feetypes" id="feetypes" class="form-control">
                                                            <option value="">Select Fee Type</option>
                                                            '.$feetype.'
                                                        </select>
                                                    </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>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `fid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#amount").val("'.$data[0]['feeamount'].'");
                        $("#terms").val("'.$data[0]['terms'].'");
                        $("#edit_id").val("'.$data[0]['fid'].'");
                        getusername();
                    </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 normalfeeconcession()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $table = '';
            {
                $date = date('Y-m-d');
                $blood = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE (`entry_date`='$date' OR `edit_date`='$date') AND (`entry_id`='$_SESSION[user_id]' OR `edit_id`='$_SESSION[user_id]') AND `fk_org_id`='$_SESSION[org_id]' AND `recieptno`='CONCESSION' AND `fk_feemode_id`='0'");
                $table = Form::dbtableed($blood, ['Hallticket Number', 'Concession Amount'], ['no', 'amount'], '/Accounts/normalfeeconcession', 'nid', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Accounts/savenormalfeecolect" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Fee Concession Details Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly>                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control">
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                            <option value="">Select Fee Type</option>
                                                            '.$feetype.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="dueamount" id="dueamount" class="form-control" placeholder="Due Amount" readonly>                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paidamount" id="paidamount" class="form-control" placeholder="Fee Amount">                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Concession Date" required="">
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="remarks" id="remarks" class="form-control" placeholder="Remarks">                                         
                                                    </div>
                                                </div>   
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="recieptno" id="recieptno" class="form-control" value="CONCESSION" placeholder="Reciept Number">                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="feemode" id="feemode" class="form-control" value="0" required>
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
                function getdueamount()
                {
                    var no = $("#no").val();
                    var year = $("#year").val();
                    var feetype = $("#feetype").val();
                    $.ajax({
                        url: "/Accounts/getdueamount",
                        type: "post",
                        data: {no: no, year: year, feetype: feetype},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("dueamount").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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>';
                }
            }
        }
    }
    /* end of fee Setting section */
    /* start of fee collection section */
    public static function examfeecollect()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $examtype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `examtype`"), 'id', 'name');
            $month = Inputs::optionsdb(Homem::getdata("SELECT * FROM `month`"), 'month_id', 'month_name');
            $table = '';
            {
                $date = date('Y-m-d');
                $blood = Homem::getdata("SELECT * FROM `stdnt_examfee` WHERE (`entry_date`='$date' OR `edit_date`='$date') AND (`entry_id`='$_SESSION[user_id]' OR `edit_id`='$_SESSION[user_id]') AND `status`='1' AND `fk_org_id`='$_SESSION[org_id]'");
                $table = Form::dbtableed($blood, ['Hallticket Number', 'Paid Amount'], ['no', 'paidamount'], '/Accounts/examfeecollect', 'eid', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Accounts/saveexamfeecollect" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Exam Fee Payment Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly>                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control">
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="sem" id="sem" class="form-control" required>
                                                            <option value="">Select Sem</option>
                                                            <option value="1">First Sem</option>
                                                            <option value="2">Second Sem</option>
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="exammonth" id="exammonth" class="form-control">
                                                            <option value="">Select Month of Exam</option>
                                                            '.$month.'
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="examyear" id="examyear" class="form-control" required>
                                                            <option value="">Select Year of Exam</option>
                                                            '.static::year().'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">                            
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="paidamount" id="paidamount" class="form-control" placeholder="Fee Amount">                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="recieptno" id="recieptno" class="form-control" placeholder="Reciept Number">                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <select name="feemode" id="feemode" class="form-control" required>
                                                            <option value="">Select Mode of Payment</option>
                                                            '.$feemode.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Fee Paid Date" required="">
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="remarks" id="remarks" class="form-control" placeholder="Remarks">                                         
                                                    </div>
                                                </div>   
                                            </div> 
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_examfee` WHERE `eid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#sem").val("'.$data[0]['sem'].'");
                        $("#exammonth").val("'.$data[0]['exammonth'].'");
                        $("#examyear").val("'.$data[0]['examyear'].'");
                        $("#paidamount").val("'.$data[0]['paidamount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paydate'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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 saveexamfeecollect()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $date = date('Y-m-d');
            if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
            {
                if($_POST['edit_id'] == '')
                {
                    Homem::insert("INSERT INTO `stdnt_examfee` (`no`, `year`, `sem`, `exammonth`, `examyear`, `paidamount`, `recieptno`, `fk_feemode_id`, `paydate`, `remarks`, `fk_org_id`, `entry_date`, `entry_id`, `edit_date`, `edit_id`, `status`) VALUES 
                    ('$_POST[no]', '$_POST[year]', '$_POST[sem]', '$_POST[exammonth]', '$_POST[examyear]', '$_POST[paidamount]', '$_POST[recieptno]', '$_POST[feemode]', '$_POST[paydate]', '$_POST[remarks]', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '', '', '1')");
                    echo '<script>window.location = "/Accounts/examfeecollect?status=1";</script>';
                }
                else
                {
                    Homem::insert("UPDATE `stdnt_examfee` SET `no`='$_POST[no]', `year`='$_POST[year]', `sem`='$_POST[sem]', `exammonth`='$_POST[exammonth]', `examyear`='$_POST[examyear]', `paidamount`='$_POST[paidamount]', `recieptno`='$_POST[recieptno]', `fk_feemode_id`='$_POST[feemode]', `paydate`='$_POST[paydate]', `remarks`='$_POST[remarks]', `edit_date`='$date', `edit_id`='$_SESSION[user_id]' WHERE `eid`='$_POST[edit_id]'");
                    echo '<script>window.location = "/Accounts/examfeecollect?status=2";</script>';
                }
            }
        }
    }
    public static function nfeecollectbulk()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4">
                            </div>
                            <div class="col-lg-4"> 
                                <form action="/Accounts/savebulknfeecollection" method="POST" enctype="multipart/form-data">                                      
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <section class="box" style="margin-top: 30px;">
                                                <header class="panel_header">
                                                    <h5 class="title pull-left">Bulk Fee Collection Entry</h5>
                                                </header>
                                                <div class="content-body">    
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">                                      
                                                                <input type="file" name="file" id="file" class="form-control" placeholder="Category Name">
                                                            </div>
                                                        </div>                              
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-lg-12">
                                                            <div class="form-group">   
                                                                <input type="hidden" name="type" id="type" class="form-control" value="bulk" placeholder="Type">                                         
                                                                <a href="/hindu/formats/stdnt_fee_collection_format.csv">Click Here to Download Uploading Format</a>
                                                            </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>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
        }
    }
    public static function savebulknfeecollection()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6)
        {
            $date = date('Y-m-d');
            if($_POST['type'] == 'bulk')
            {
                $filename=$_FILES['file']['name'];
                $exts[0]='csv';
                $filetype1 = explode('.',$filename);
                if($_FILES['file']['name']!=null && $filetype1[sizeof($filetype1)-1] == $exts[0])
                {
                    $csv_file=$_FILES['file']['tmp_name'];
                    $size=$_FILES['file']['size'];
                    $handle = fopen($csv_file, "r");
                    $data = fgetcsv($handle, 100000, ",");
                    $i = 0;
                    $j = 0;
                    $regdate = date('Y-m-d');
                    while (($data = fgetcsv($handle, 100000, ","))!== FALSE)
                    {
                        $htno =  trim($data[0]);
                        $year =  trim($data[1]);
                        $feetype =  trim($data[2]);
                        $amount =  trim($data[3]);
                        $reciept =  trim($data[4]);
                        $mode = trim($data[5]);
                        $date = trim($data[6]);
                        $remarks = trim($data[7]);
                        $udata = Homem::getdata("SELECT * FROM `user_master` WHERE `ano`='$htno' OR `no`='$htno'");
                        if(sizeof($udata) == 1)
                        {
                            $sid = $udata[0]['id'];
                            $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `no`='$sid' AND `year`='$year' AND `fk_feetype_id`='$feetype' AND `amount`='$amount' AND `recieptno`='$reciept' AND `paid_date`='$date'");
                            $key = explode("-", $date);
                            // echo sizeof($key);
                            if(sizeof($data) == 0 && strlen($date)==10 && sizeof($key) == 3)
                            {
                                $i++;
                                
                                    Homem::insert("INSERT INTO `stdnt_normalfee` (`no`, `year`, `fk_feetype_id`, `amount`, `recieptno`, `fk_feemode_id`, `paid_date`, `remarks`, `fk_org_id`, `entry_date`, `entry_id`, `edit_date`, `edit_id`) VALUES ('$sid', '$year', '$feetype', '$amount', '$reciept', '$mode', '$date', '$remarks', '$_SESSION[org_id]', '$regdate', '$_SESSION[user_id]', '', '')");
                            }
                            else
                            {
                                $j++;
                            }
                        }
                        else
                        {
                            $j++;
                        }
                    }
                    echo '<script>window.location="/Accounts/nfeecollectbulk?status=1&count='.$i.'&duplicate='.$j.'";</script>';
                }
            }
        }
    }
    public static function getusername()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $data[0]['name']= '';
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `no`='$_POST[no]'");
            echo $data[0]['name'];
        }
    }
    public static function normalfeecolect()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $feemode = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_mode`"), 'id', 'name');
            $table = '';
            {
                $date = date('Y-m-d');
                // $blood = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE (`entry_date`='$date' OR `edit_date`='$date') AND (`entry_id`='$_SESSION[user_id]' OR `edit_id`='$_SESSION[user_id]') AND `fk_org_id`='$_SESSION[org_id]'");
                $blood = Homem::getdata("SELECT * FROM stdnt_normalfee sn JOIN user_master um ON um.id=sn.no WHERE (sn.entry_date='$date' OR sn.edit_date='$date') AND (sn.entry_id='$_SESSION[user_id]' OR sn.edit_id='$_SESSION[user_id]') AND sn.fk_org_id='$_SESSION[org_id]'");
                $table = Form::dbtableed($blood, ['Admission Number', 'Hallticket Number', 'Name', 'Reciept Number', 'Paid Amount'], ['ano', 'no', 'name', 'recieptno', 'amount'], '/Accounts/normalfeecolect', '', '');
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"> 
                            </div>
                            <div class="col-lg-4">
                                <form action="/Accounts/savenormalfeecolect" method="POST" enctype="multipart/form-data">
                                    <section class="box" style="margin-top: 30px;">
                                        <header class="panel_header">
                                            <h5 class="title pull-left">Individual Fee Payment Entry</h5>
                                        </header>
                                        <div class="content-body"> 
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="no" id="no" class="form-control" placeholder="Hallticket Number" onchange="getusername()">                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-lg-12">
                                                    <div class="form-group">   
                                                        <input type="text" name="name" id="name" class="form-control" placeholder="Student Name" readonly>                                         
                                                    </div>
                                                </div>                              
                                            </div>   
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">                                            
                                                        <select name="year" id="year" class="form-control" required>
                                                            <option value="">Select Year to which fee applicable</option>
                                                            <option value="1">First Year</option>
                                                            <option value="2">Second Year</option>
                                                            <option value="3">Third Year</option>
                                                            <option value="4">Fourth Year</option>
                                                        </select>												
                                                    </div>
                                                </div>                              
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                            <option value="">Select Fee Type</option>
                                                            '.$feetype.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="dueamount" id="dueamount" class="form-control" placeholder="Due Amount" readonly>                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paidamount" id="paidamount" class="form-control" placeholder="Fee Amount" required>                                         
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="recieptno" id="recieptno" class="form-control" placeholder="Reciept Number" required>                                         
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <select name="feemode" id="feemode" class="form-control" required>
                                                            <option value="">Select Mode of Payment</option>
                                                            '.$feemode.'
                                                        </select>
                                                    </div>
                                                </div>                              
                                            </div> 
                                            <div class="row">
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="paydate" id="paydate" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Fee Paid Date" required>
                                                    </div>
                                                </div>                              
                                                <div class="col-lg-6">
                                                    <div class="form-group">   
                                                        <input type="text" name="remarks" id="remarks" class="form-control" placeholder="Remarks">                                         
                                                    </div>
                                                </div>   
                                            </div> 
                                            <div class="row"> 
                                                <div class="col-lg-12">
                                                    <div class="form-group"> 
                                                        <input type="hidden" name="sid" id="sid" class="form-control" placeholder="user id" required>
                                                        <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">                                         
                                                    </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>
                                    </selection>
                                </form>
                            </div>
                            <div class="col-lg-4">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2"></div>
                            <div class="col-lg-8">
                            '.$table.'
                            </div>
                            <div class="col-lg-2"></div>
                        </div>
                    </div>
                
                ';
            echo '</body>';
            echo static::script();
            echo '
            <script>
                function getusername()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getusername",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            document.getElementById("name").value = d;
                            getuserid();
                        }
                    });
                }
                function getdueamount()
                {
                    var no = $("#no").val();
                    var year = $("#year").val();
                    var feetype = $("#feetype").val();
                    $.ajax({
                        url: "/Accounts/getdueamount",
                        type: "post",
                        data: {no: no, year: year, feetype: feetype},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("dueamount").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
                function getuserid()
                {
                    var no = $("#no").val();
                    $.ajax({
                        url: "/Accounts/getuserid",
                        type: "post",
                        data: {no: no},
                        success: function(d) {
                            if(d != "fail")
                            {
                                document.getElementById("sid").value = d;
                                $("#btn_reg").show();
                            }
                            else
                            {
                                $("#btn_reg").hide();
                            }
                        }
                    });
                }
            </script>';
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `nid`='$_GET[editid]' AND `fk_org_id`='$_SESSION[org_id]'");
                if(sizeof($data) == 1)
                {
                    echo '
                    <script>
                        $("#no").val("'.$data[0]['no'].'");
                        $("#year").val("'.$data[0]['year'].'");
                        $("#feetype").val("'.$data[0]['fk_feetype_id'].'");
                        $("#paidamount").val("'.$data[0]['amount'].'");
                        $("#recieptno").val("'.$data[0]['recieptno'].'");
                        $("#feemode").val("'.$data[0]['fk_feemode_id'].'");
                        $("#paydate").val("'.$data[0]['paid_date'].'");
                        $("#remarks").val("'.$data[0]['remarks'].'");
                        $("#edit_id").val("'.$_GET['editid'].'");
                        getusername();
                    </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 savenormalfeecolect()
    {
        $date = date('Y-m-d');
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $data = Homem::getdata("SELECT * FROM `user_master` WHERE `id`='$_POST[sid]' AND (`ano`='$_POST[no]' OR `no`='$_POST[no]')");
            $data1 = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `no`='$_POST[sid]' AND `year`='$_POST[year]' AND `fk_feetype_id`='$_POST[feetype]' AND `amount`='$_POST[paidamount]' AND `recieptno`='$_POST[recieptno]' AND `paid_date`='$_POST[paydate]'");
            if(sizeof($data) == 1)
            {
                if($_POST['edit_id'] == '')
                {
                    if(sizeof($data1) == 0)
                    {
                        Homem::insert("INSERT INTO `stdnt_normalfee` (`no`, `year`, `fk_feetype_id`, `amount`, `recieptno`, `fk_feemode_id`, `paid_date`, `remarks`, `fk_org_id`, `entry_date`, `entry_id`, `edit_date`, `edit_id`) VALUES 
                        ('$_POST[sid]', '$_POST[year]', '$_POST[feetype]', '$_POST[paidamount]', '$_POST[recieptno]', '$_POST[feemode]', '$_POST[paydate]', '$_POST[remarks]', '$_SESSION[org_id]', '$date', '$_SESSION[user_id]', '', '')");
                        echo '<script>window.location = "/Accounts/normalfeecolect?status=1";</script>';
                    }
                    else
                    {
                        echo '<script>window.location = "/Accounts/normalfeecolect?status=0";</script>';
                    }
                }
                else
                {
                    Homem::insert("UPDATE `stdnt_normalfee` SET `no`='$_POST[sid]', `year`='$_POST[year]', `fk_feetype_id`='$_POST[feetype]', `amount`='$_POST[paidamount]', `recieptno`='$_POST[recieptno]', `fk_feemode_id`='$_POST[feemode]', `paid_date`='$_POST[paydate]', `remarks`='$_POST[remarks]', `edit_date`='$date', `edit_id`='$_SESSION[user_id]' WHERE `nid`='$_POST[edit_id]'");
                    echo '<script>window.location = "/Accounts/normalfeecolect?status=2";</script>';
                }
            }
            else
            {
                echo '<script>window.location = "/Accounts/normalfeecolect?status=0";</script>';
            }
        }
    }
    public static function getdueamount()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_POST['no']) && isset($_POST['year']) && isset($_POST['feetype']))
            {
                $data = Homem::getdata("SELECT * FROM `user_master` WHERE (`ano`='$_POST[no]' OR `no`='$_POST[no]') AND `user_role`='3'");
                if(sizeof($data) == 1)
                {
                    $sid = $data[0]['id'];
                    $setdata = Homem::getdata("SELECT * FROM `stdnt_feemaster` WHERE `no`='$sid' AND `year`='$_POST[year]' AND `fk_feetype_id`='$_POST[feetype]'");
                    if(sizeof($setdata) == 1)
                    {
                        $feedata = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `no`='$sid' AND `year`='$_POST[year]' AND `fk_feetype_id`='$_POST[feetype]'");
                        if(sizeof($feedata) == 0)
                        {
                            echo $setdata[0]['feeamount'];
                        }
                        if(sizeof($feedata) == 1)
                        {
                            $due = $setdata[0]['feeamount']-$feedata[0]['amount'];
                            echo $due;
                        }
                        if(sizeof($feedata) > 1)
                        {
                            $total = 0;
                            for($i=0; $i<sizeof($feedata); $i++)
                            {
                                $total = $total+$feedata[$i]['amount'];
                            }
                            $due = $setdata[0]['feeamount']-$total;
                            echo $due;
                        }
                    }
                    else
                    {
                        echo 'fail';
                    }
                }
            }
        }
    }
    public static function getuserid()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if($_POST['no'] != '')
            {
                $data = Homem::getdata("SELECT * FROM `user_master` WHERE (`ano`='$_POST[no]' OR `no`='$_POST[no]') AND `user_role`='3'");
                if(sizeof($data) == 1)
                {
                    echo $data[0]['id'];
                }
            }
        }
    }
    public static function hnowiseconsreport()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['htno']))
            {
                $sdata = Homem::getdata("SELECT * FROM `user_master` WHERE `no`='$_POST[htno]'");
                $uid = '';
                if(sizeof($sdata) > 0)
                {
                    $uid = $sdata[0]['id'];
                }
                $mdata = Homem::getdata("SELECT * FROM stdnt_feemaster sn JOIN user_master um ON um.id=sn.no WHERE sn.no='$uid'");
                $fdata = Homem::getdata("SELECT * FROM user_details WHERE `ht_no`='$_POST[htno]'");
                $data = Homem::getdata("SELECT * FROM stdnt_normalfee sn JOIN user_master um ON um.id=sn.no JOIN user_master uma on uma.id=sn.entry_id WHERE sn.no='$uid'");
                $photo = Homem::getdata("SELECT * FROM `stdent_photos` WHERE `no`='$_POST[htno]'");
                $image = '';
                if(isset($photo[0]['photo']))
                {
                    $image = '<img src="'.$photo[0]['photo'].'" width="250px" height="300px">';
                }
                if(sizeof($mdata) > 0)
                {
                    $feetype = array();
                    $feeyear = array();
                    foreach ($mdata as $h) {
                        $feetype[] = $h['fk_feetype_id'];
                        $feeyear[] = $h['year'];
                    }
                    $ftype = array_values(array_unique($feetype));
                    sort($ftype);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    // calculate year row span
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $cnt = 0;
                        for($k=0; $k<sizeof($data); $k++)
                        {
                            if($data[$k]['year'] == $fyear[$j])
                            {
                                $cnt++;
                            }
                            if($k == sizeof($data)-1)
                            {
                                $f[$fyear[$j]] = $cnt;
                            }
                        }
                    }
                    // calculate year, feetype row span
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        for($i=0; $i<sizeof($ftype); $i++)
                        {
                            $b = 0;
                            $paida = 0;
                            for($l=0; $l<sizeof($data); $l++)
                            {
                                if($data[$l]['year'] == $fyear[$j] && $data[$l]['fk_feetype_id'] == $ftype[$i])
                                {
                                    $b++;  
                                    $paida = $paida+$data[$l]['amount'];
                                }
                                if($l == sizeof($data)-1)
                                {
                                    $c[$fyear[$j]][$ftype[$i]] = $b;
                                    $paid[$fyear[$j]][$ftype[$i]] = $paida;
                                }
                            }
                            for($l=0; $l<sizeof($mdata); $l++)
                            {
                                if($mdata[$l]['year'] == $fyear[$j] && $mdata[$l]['fk_feetype_id'] == $ftype[$i])
                                {
                                    $actual[$fyear[$j]][$ftype[$i]] = $mdata[$l]['feeamount'];
                                }
                            }
                            for($l=0; $l<sizeof($mdata); $l++)
                            {
                                if($mdata[$l]['year'] == $fyear[$j] && $mdata[$l]['fk_feetype_id'] == $ftype[$i])
                                {
                                    if(!isset($paid[$fyear[$j]][$ftype[$i]]))
                                    {
                                        $paid[$fyear[$j]][$ftype[$i]] = 0;
                                    }
                                    $due[$fyear[$j]][$ftype[$i]] = $actual[$fyear[$j]][$ftype[$i]]-$paid[$fyear[$j]][$ftype[$i]];
                                }
                            }
                        }
                    }
                    // echo json_encode($paid);
                    $tactual = 0;
                    $tpaid = 0;
                    $tdue = 0;
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $e = 1;
                        $g = 0;
                        $newcount = 0;
                        for($i=0; $i<sizeof($ftype); $i++)
                        {
                            for($l=0; $l<sizeof($mdata); $l++)
                            {
                                if($mdata[$l]['year'] == $fyear[$j] && $mdata[$l]['fk_feetype_id'] == $ftype[$i])
                                {
                                    $b = 0;
                                    $cd = 0;
                                    for($k=0; $k<sizeof($data); $k++)
                                    {
                                        if($data[$k]['year'] == $fyear[$j] && $data[$k]['fk_feetype_id'] == $ftype[$i])
                                        {
                                            $b++;
                                            $g++;
                                            if($b == 1 && $e ==1 && $g==1)
                                            {
                                                $a .= '<tr>
                                                            <td rowspan="'.$f[$fyear[$j]].'">'.static::nyear($fyear[$j]).'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.static::feetype($ftype[$i]).'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$actual[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$paid[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$due[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td>'.$data[$k]['recieptno'].'</td>
                                                            <td>'.$data[$k]['amount'].'</td>
                                                            <td>'.static::datem($data[$k]['paid_date']).'</td>
                                                        </tr>
                                                    ';
                                                $tactual = $tactual+$actual[$fyear[$j]][$ftype[$i]];
                                                $tpaid = $tpaid+$paid[$fyear[$j]][$ftype[$i]];
                                                $tdue = $tdue+$due[$fyear[$j]][$ftype[$i]];
                                                $e = 0;
                                                $cd = 1;
                                                $completed[$fyear[$j]][$ftype[$i]] = 1;
                                            }
                                            if(isset($s[$fyear[$j]][$ftype[$i]]))
                                            {
                                                $a .= '<tr>
                                                            <td>'.$data[$k]['recieptno'].'</td>
                                                            <td>'.$data[$k]['amount'].'</td>
                                                            <td>'.static::datem($data[$k]['paid_date']).'</td>
                                                        </tr>
                                                    ';
                                                $newcount = $newcount+1;
                                            }
                                            if(isset($subcompleted[$fyear[$j]][$ftype[$i]]) && $newcount == 1)
                                            {
                                                $a .= '<tr>
                                                            <td>'.$data[$k]['recieptno'].'</td>
                                                            <td>'.$data[$k]['amount'].'</td>
                                                            <td>'.static::datem($data[$k]['paid_date']).'</td>
                                                        </tr>
                                                    ';
                                                $s[$fyear[$j]][$ftype[$i]] = 1;
                                            }
                                            if(!isset($completed[$fyear[$j]][$ftype[$i]]) && $e ==0 && !isset($subcompleted[$fyear[$j]][$ftype[$i]]))
                                            {
                                                $a .= '<tr>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.static::feetype($ftype[$i]).'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$actual[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$paid[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td rowspan="'.$c[$fyear[$j]][$ftype[$i]].'">'.$due[$fyear[$j]][$ftype[$i]].'</td>
                                                            <td>'.$data[$k]['recieptno'].'</td>
                                                            <td>'.$data[$k]['amount'].'</td>
                                                            <td>'.static::datem($data[$k]['paid_date']).'</td>
                                                        </tr>
                                                    ';
                                                    $tactual = $tactual+$actual[$fyear[$j]][$ftype[$i]];
                                                    $tpaid = $tpaid+$paid[$fyear[$j]][$ftype[$i]];
                                                    $tdue = $tdue+$due[$fyear[$j]][$ftype[$i]];
                                                    $subcompleted[$fyear[$j]][$ftype[$i]] = 1;
                                                    $newcount = 1;
                                            }
                                            
                                            if($e == 0 && $b>1 && $newcount == 0)
                                            {
                                                $a .= '<tr>
                                                            <td>'.$data[$k]['recieptno'].'</td>
                                                            <td>'.$data[$k]['amount'].'</td>
                                                            <td>'.static::datem($data[$k]['paid_date']).'</td>
                                                        </tr>
                                                    ';
                                            }
                                            if($k == sizeof($data)-1)
                                            {
                                                $g = 0;
                                                // echo 'tets';
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $a .= '<tr><td colspan="2"><b>Total</b></td><td><b>'.$tactual.'</b></td><td><b>'.$tpaid.'</b></td><td><b>'.$tdue.'</b></td><td colspan="3"></td></tr>';
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                    }
                    $cheader='';
                    $cheader=static::indstdntfeereport();
                    if(sizeof($fdata) == 1)
                    {
                        $head = '<thead>
                                '.$cheader.'
                                <tr>
                                    <th colspan="2">Hall Ticket Number</th><th colspan="3">'.$_POST['htno'].'</th>
                                    <th rowspan="6" colspan="3">'.$image.'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Name of the Student</th><th colspan="3">'.$mdata[0]['name'].'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Father Name</th><th colspan="3">'.$fdata[0]['fname'].'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Course</th><th colspan="3">'.static::course($mdata[0]['fk_course_id']).' ('.static::squota($mdata[0]['squota'], $mdata[0]['fk_course_id']).')</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Department</th><th colspan="3">'.static::dept($mdata[0]['fk_dept_id']).'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Acadamic Year</th><th colspan="3">'.$mdata[0]['fromyear'].' - '.$mdata[0]['toyear'].'</th>
                                </tr>
                                <tr>
                                    <th>Year</th>
                                    <th>Fee Type</th>
                                    <th>Actual Amount</th>
                                    <th>Paid Amount</th>
                                    <th>Due Amount</th>
                                    <th>Bill Number</th>
                                    <th>Amount Paid</th>
                                    <th>Paid Date</th>
                                </tr>
                            </thead>';
                    }
                    else
                    {
                        $head = '<thead>
                                '.$cheader.'
                                <tr>
                                    <th colspan="2">Hall Ticket Number</th><th colspan="3">'.$_POST['htno'].'</th>
                                    <th rowspan="5" colspan="3">'.$image.'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Name of the Student</th><th colspan="3">'.$mdata[0]['name'].'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Course</th><th colspan="3">'.static::course($mdata[0]['fk_course_id']).' ('.static::squota($mdata[0]['squota'], $mdata[0]['fk_course_id']).')</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Department</th><th colspan="3">'.static::dept($mdata[0]['fk_dept_id']).'</th>
                                </tr>
                                <tr>
                                    <th colspan="2">Acadamic Year</th><th colspan="3">'.$mdata[0]['fromyear'].' - '.$mdata[0]['toyear'].'</th>
                                </tr>
                                <tr>
                                    <th>Year</th>
                                    <th>Fee Type</th>
                                    <th>Actual Amount</th>
                                    <th>Paid Amount</th>
                                    <th>Due Amount</th>
                                    <th>Bill Number</th>
                                    <th>Amount Paid</th>
                                    <th>Paid Date</th>
                                </tr>
                            </thead>';
                    }
                    
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm print-this" 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">Individual Student Fee 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-12">
                                                        <div class="form-group">                                            
                                                            <input placeholder="Hall Ticket Number" class="form-control" name="htno" id="htno" >
                                                        </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 slist()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $a = '';
            if(isset($_POST['course']))
            {
                $data = Homem::getdata("SELECT * FROM `user_master` WHERE `fk_course_id`='$_POST[course]' AND `fk_dept_id`='$_POST[department]' AND `org_id`='$_SESSION[org_id]' AND `fromyear`='$_POST[fromyear]' AND `toyear`='$_POST[toyear]' AND `user_role`='3' ORDER BY `no` ASC");
                if(sizeof($data) > 0)
                {
                    $table = Form::dbtableed($data, ['Admission Number', 'Hall Ticket Number', 'Name', 'Gender'], ['ano', 'no', 'name', 'gender'], '/Accounts/addstudent', 'id', '');
                    $a = '
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                '.$table.'
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        ';
                }
            }
            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">List by Department</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 name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control">
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="fromyear" id="fromyear" class="form-control">
                                                            <option value="">Starting Year</option>
                                                            ';
                                                            echo $styear;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="toyear" id="toyear" class="form-control">
                                                            <option value="">Ending Year</option>
                                                            ';
                                                            echo $enyear;
                                                            echo '
                                                            </select>
                                                        </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>'.$a.'
                    </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 addstudent()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            $blood = Inputs::optionsdb(Homem::getdata("SELECT * FROM `blood_group`"), 'id', 'name');
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Accounts/saveaddstudent" 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">
                                                <h4 class="title pull-left">ADD NEW STUDENT</h4>
                                                <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 type="text" name="admission" id="admission" class="form-control" placeholder="Admission Number" required>
                                                        </div>
                                                    </div>      
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                      
                                                            <select type="text" name="quota" id="quota" class="form-control" required>
                                                                <option value="">Select Admission Type</option>    
                                                                <option value="C">Convener Quota</option>
                                                                <option value="M">Management Quota</option>
                                                                <option value="S">Spot Admission</option>
                                                            </select>
                                                        </div>
                                                    </div>                          
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                      
                                                            <input type="text" name="hallticket" id="hallticket" class="form-control" placeholder="Hall Ticket Number" required>
                                                        </div>
                                                    </div>                              
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="name" id="name" class="form-control" placeholder="Student Name">
                                                        </div>
                                                    </div>                              
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">  
                                                            <input type="text" name="dob" id="dob" class="form-control" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" placeholder="Date of Birth">                                          
                                                        </div>
                                                    </div>                              
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="gender" id="gender" class="form-control">
                                                            <option value="">Select Gender</option>
                                                            <option value="M">Male</option>
                                                            <option value="F">Female</option>
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="bloodgroup" id="bloodgroup" class="form-control">
                                                            <option value="">Select Blood Group</option>
                                                            '; 
                                                            echo $blood;
                                                            echo '</select>
                                                        </div>
                                                    </div> 	
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="nyears" id="nyears" class="form-control">
                                                            <option value="">Number of Years of Course</option>
                                                            <option value="1">1</option>
                                                            <option value="2">2</option>
                                                            <option value="3">3</option>
                                                            <option value="4">4</option>
                                                            </select>
                                                        </div>
                                                    </div>  									
                                                </div>  
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control">
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="fromyear" id="fromyear" class="form-control">
                                                            <option value="">Starting Year</option>
                                                            ';
                                                            echo static::year();
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select name="toyear" id="toyear" class="form-control">
                                                            <option value="">Ending Year</option>
                                                            ';
                                                            echo static::year();
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="regulation" id="regulation" class="form-control" placeholder="Regulation">
                                                        </div>
                                                    </div> 										
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="mobile" id="mobile" class="form-control" placeholder="Mobile Number" maxlength="10" onkeypress="return isNumber(event)">
                                                        </div>
                                                    </div>  									
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="text" name="email" id="email" class="form-control" placeholder="Email Address">
                                                        </div>
                                                    </div>  										
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-12">
                                                        <div class="form-group">                                            
                                                            <input type="hidden" name="edit_id" id="edit_id" class="form-control" placeholder="edit id">
                                                        </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>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success"); delay(5000); window.location.href="/Accounts/home";</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success"); delay(5000); window.location.href="/Accounts/home"; </script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error"); delay(5000); window.location="/Accounts/home";</script>';
                }
            }
        }
    }
    public static function saveaddstudent()
    {
        if($_SESSION['user_role'] != '')
        {
            if($_POST['edit_id'] == '')
            {
                $mdata = 0;
                if($_POST['mobile'] != '')
                {
                    $mdata = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `mobile`='$_POST[mobile]'"));
                }
                $edata = 0;
                if($_POST['email'] != '')
                {
                    $edata = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `email`='$_POST[email]'"));
                }
                $data = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `no`='$_POST[hallticket]' AND `org_id`='$_SESSION[org_id]'"));
                if($mdata == 0 && $edata == 0 && $data == 0)
                {
                    $date = date('Y-m-d');
                    // $query = "INSERT INTO `user_master`(`no`, `name`, `dob`, `gender`, `blood_group`, `fk_course_id`, `fk_dept_id`, `org_id`, `fromyear`, `toyear`, `regulation`, `mobile`, `email`, `password`, `user_role`, `status`) VALUES ('$_POST[hallticket]', '$_POST[name]', '$_POST[dob]', '$_POST[gender]', '$_POST[bloodgroup]', '$_POST[course]', '$_POST[department]', '$_SESSION[org_id]', '$_POST[fromyear]', '$_POST[toyear]', '$_POST[regulation]', '$_POST[mobile]', '$_POST[email]', '$_POST[hallticket]', '3', '1')";
                    $query = "INSERT INTO `user_master` (`id`, `ano`, `roll_no`, `section`, `medieum`, `adm_type`, `squota`, `noofyears`, `no`, `name`, `fname`, `fmobile`, `dob`, `gender`, `blood_group`, `fk_course_id`, `fk_dept_id`, `lateral`, `org_id`, `fromyear`, `toyear`, `regulation`, `mobile`, `email`, `password`, `user_role`, `status`, `v_mobile`, `v_email`, `add_by`, `add_date`, `discontinued`, `tc_given`) VALUES (NULL, '$_POST[admission]', '$_POST[hallticket]', '', '', '$_POST[quota]', '', '', '$_POST[hallticket]', '$_POST[name]', '', '', '$_POST[dob]', '$_POST[gender]', '$_POST[bloodgroup]', '$_POST[course]', '$_POST[department]', '', '$_SESSION[org_id]', '$_POST[fromyear]', '$_POST[toyear]', '$_POST[regulation]', '$_POST[mobile]', '$_POST[email]', '123456789', '3', '1', '', '', '$_SESSION[user_id]', '$date', '', '')";
                    Homem::insert($query);
                    echo '<script>window.location = "/Accounts/addstudent?status=1";</script>';
                }
                else
                {
                    echo '<script>window.location = "/Accounts/addstudent?status=0";</script>';
                }
            }
            // else
            // {
            //     $mdata = 0;
            //     if($_POST['mobile'] != '')
            //     {
            //         $mdata1 = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `mobile`='$_POST[mobile]' OR `id`='$_POST[edit_id]'"));
            //         if($mdata1 == 1)
            //         {
            //             $mdata2 = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `mobile`='$_POST[mobile]' AND `id`='$_POST[edit_id]'"));
            //             if(($mdata2 == 0) || ($mdata2 == 1))
            //             {
            //                 $mdata = 0;
            //             }
            //             else
            //             {
            //                 $mdata = 1;
            //             }
            //         }
            //         else
            //         {
            //             $mdata = 1;
            //         }
            //     }
            //     $edata = 0;
            //     if($_POST['email'] != '')
            //     {
            //         $edata1 = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `email`='$_POST[email]' OR `id`='$_POST[edit_id]'"));
            //         if($edata1 == 1)
            //         {
            //             $edata2 = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `email`='$_POST[email]' AND `id`='$_POST[edit_id]'"));
            //             if(($edata2 == 0) || ($edata2 == 1))
            //             {
            //                 $edata = 0;
            //             }
            //             else
            //             {
            //                 $edata = 1;
            //             }
            //         }
            //         else
            //         {
            //             $edata = 1;
            //         }
            //     }
            //     $data = sizeof(Homem::getdata("SELECT * FROM `user_master` WHERE `id`='$_POST[edit_id]' AND `org_id`='$_SESSION[org_id]'"));
            //     if($mdata == 0 && $edata == 0 && $data == 1)
            //     {
            //         $query = "UPDATE `user_master` SET `ano`='$_POST[admission]', `squota`='$_POST[quota]', `noofyears`='$_POST[nyears]', `no`='$_POST[hallticket]', `name`='$_POST[name]', `dob`='$_POST[dob]', 
            //         `gender`='$_POST[gender]', `blood_group`='$_POST[bloodgroup]', `fk_course_id`='$_POST[course]', 
            //         `fk_dept_id`='$_POST[department]', `org_id`='$_SESSION[org_id]', `fromyear`='$_POST[fromyear]', 
            //         `toyear`='$_POST[toyear]', `regulation`='$_POST[regulation]', `mobile`='$_POST[mobile]', `email`='$_POST[email]', `password`='$_POST[hallticket]', 
            //         `user_role`='3', `status`='1' WHERE `id`='$_POST[edit_id]'";
            //         Homem::insert($query);
            //         echo '<script>window.location = "/Accounts/addstudent?status=2";</script>';
            //     }
            //     else
            //     {
            //         echo '<script>window.location = "/Accounts/addstudent?status=0";</script>';
            //     }
            // }
        }
    }
    public static function print()
    {
        if($_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 4)
        {
            if(isset($_GET['editid']))
            {
                $data = Homem::getdata("SELECT a.*, fm.name as feemode, u.name as opname FROM (SELECT sn.recieptno, sn.amount, sn.paid_date, sn.year, sn.fk_feetype_id, sn.fk_feemode_id, sn.entry_id, um.no, um.name, um.fk_course_id, um.fk_dept_id FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id WHERE sn.nid='$_GET[editid]') a JOIN fee_mode fm ON a.fk_feemode_id=fm.id JOIN user_master u ON a.entry_id=u.id");
            }
            if(sizeof($data) == 1)
            {
                echo static::css();
                echo '<body>';
                echo $_SESSION['menu'];
                echo '
                    <form action="" method="POST">
                        <div class="container-fluid">
                            <div class="row print-this">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <br/ ><br/ ><br/ ><br/ >
                                    <div style="border: solid 1px black; border-radius: 10px;">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <table width="100%">
                                                    <tbody>
                                                        '.static::recieptheader().'
                                                        <tr>
                                                            <td><span style="margin-left: 10px;">Reciept Number: '.$data[0]['recieptno'].'</span></td>
                                                            <td style="text-align: right;"><span style="margin-right: 10px;">Date: '.static::datem($data[0]['paid_date']).'</span></td>
                                                        </tr>
                                                        <tr>
                                                            <td colspan="2">
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Name : &nbsp; </b>'.$data[0]['name'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Department :  &nbsp; </b>'.static::course($data[0]['fk_course_id']).'-'.static::dept($data[0]['fk_dept_id']).'</span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>HT No. / PIN : &nbsp; </b>'.$data[0]['no'].'</span>
                                                            </td>
                                                            <td width="50%">
                                                                <span style="margin-left: 10px;"><b>Year :  &nbsp; </b>'.static::nyear($data[0]['year']).'</span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="90%" align="center" style="border: 2px single black;">
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                <b>Fee Particulars</b>
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                <b>Amount (Rs.)</b>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                    <tbody>
                                                        <tr style="text-align: center;">
                                                            <td width="70%" style="border: thin solid black">
                                                                '.static::feetype($data[0]['fk_feetype_id']).'
                                                            </td>
                                                            <td width="30%" style="border: thin solid black">
                                                                '.number_format($data[0]['amount'], 2).'
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                                <table width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td colspan="2">
                                                                <span style="margin-left: 10px;"><b>Amount in words: </b>'.static::numtotext($data[0]['amount']).'</span>
                                                            </td>
                                                            <td style="text-align: right;">
                                                                <span style="margin-right: 10px;">
                                                                    <b>Mode of payment: </b> '.$data[0]['feemode'].'
                                                                </span>
                                                            </td>
                                                        </tr>
                                                        <tr style="text-align: center;">
                                                            <td colspan="3" style="text-align: right;">
                                                                <span style="margin-right: 10px; margin-top: 20px;">
                                                                    <br><br><br>
                                                                    <b>Office Inchage / Accountant </b> <br>('.$data[0]['opname'].')
                                                                </span>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                            <div class="row">
                                <div class="col-lg-1"></div>
                                <div class="col-lg-10">
                                    <button onclick="window.print()">Print this page</button>
                                </div>
                                <div class="col-lg-1"></div>
                            </div>
                        </div>
                    </form>';
            }
            echo '</body>';
            echo static::script();
        }
    }
    /* end of fee collection section */

    public static function deptwiseconsol()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 ||  $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $subtable = '';
            $a = '';
            if(isset($_POST['course']))
            {
                if($_POST['squota'] == 1)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM  stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]'");
                    $paiddata = Homem::getdata("SELECT * FROM  stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]'");
                }
                if($_POST['squota'] == 2)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]'");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]'");
                
                }
                if($_POST['squota'] == 'ALL')
                {
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]'");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]'");
                
                }
                if(sizeof($masterdata) > 0)
                {
                    $ht_no = array();
                    $feeyear = array();
                    foreach ($masterdata as $h) {
                        $ht_no[] = $h['no'];
                        $feeyear[] = $h['year'];
                    }
                    $no = array_values(array_unique($ht_no));
                    sort($no);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            for($k=0; $k<sizeof($masterdata); $k++)
                            {
                                if($masterdata[$k]['no'] == $no[$i] && $masterdata[$k]['year'] == $fyear[$j])
                                {
                                    $data[$no[$i]]['name'] = $masterdata[$k]['name'];
                                    $data[$no[$i]]['quota'] = $masterdata[$k]['squota'];
                                    $data[$no[$i]][$fyear[$j]]['actualamount'] = $masterdata[$k]['feeamount'];
                                }
                                if($k == sizeof($masterdata)-1)
                                {
                                    if(!isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['actualamount'] = 0;
                                    }
                                }
                            }
                            $totalamount = 0;
                            if(sizeof($paiddata) > 0)
                            {
                                for($k=0; $k<sizeof($paiddata); $k++)
                                {
                                    if($paiddata[$k]['no'] == $no[$i] && $paiddata[$k]['year'] == $fyear[$j])
                                    {
                                        $totalamount = $totalamount+$paiddata[$k]['amount'];
                                    }
                                    $count = sizeof($paiddata)-1;
                                    if($k == $count && !isset($data[$no[$i]][$fyear[$j]]['paidamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['paidamount'] = $totalamount;
                                        if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                        {
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = $data[$no[$i]][$fyear[$j]]['actualamount']-$totalamount;
                                        }
                                        else
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                        if($data[$no[$i]][$fyear[$j]]['actualamount'] == 0)
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                            }
                        }
                    }
                    if($_POST['year'] == "ALL")
                    {
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            $count = 0;
                            $totaldue = 0;
                            $totalpaid = 0;
                            $totalactual = 0;
                            $sno = $i+1;
                            $a.='<tr>';
                            $a.='<td>'.$sno.'</td>';
                            $a.='<td>'.$no[$i].'</td>';
                            $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                            $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                            for($k=0; $k<sizeof($data); $k++)
                            {
                                for($j=0; $j<sizeof($fyear); $j++)
                                {
                                    if($count < sizeof($fyear))
                                    {
                                        if($_POST['year'] == "ALL")
                                        {
                                            if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                            {
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['actualamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['paidamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['dueamount'].'</td>';
                                                $count++;
                                                $totalactual = $totalactual+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                                $totalpaid = $totalpaid+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                                $totaldue = $totaldue+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                            }
                                        }
                                        
                                    }
                                }
                            }
                            $a.='<td>'.$totalactual.'</td>';
                            $a.='<td>'.$totalpaid.'</td>';
                            $a.='<td>'.$totaldue.'</td>';
                            $a.='</tr>';
                        }
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $actualfee = 0;
                            $paidfee = 0;
                            $duefee = 0;
                            for($i=0; $i<sizeof($no); $i++)
                            {
                                for($k=0; $k<sizeof($data); $k++)
                                {
                                    $actualfee = $actualfee+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                    $paidfee = $paidfee+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                    $duefee = $duefee+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                }
                            }
                            $afee[$fyear[$j]] = $actualfee/sizeof($no);
                            $pfee[$fyear[$j]] = $paidfee/sizeof($no);
                            $dfee[$fyear[$j]] = $duefee/sizeof($no);
                        }
                        $a .= '<tr>';
                        $a .= '<td colspan="3">Total Fee Collection Details</td>';
                        $a .= '<td></td>';
                        $t1 = 0;
                        $t2 = 0;
                        $t3 = 0;
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $t1 = $t1+$afee[$fyear[$j]];
                            $t2 = $t2+$pfee[$fyear[$j]];
                            $t3 = $t3+$dfee[$fyear[$j]];
                            $a .= '<td>'.$afee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$pfee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$dfee[$fyear[$j]].'</td>';
                            if($j == sizeof($fyear)-1)
                            {
                                $a .= '<td>'.$t1.'</td>';
                                $a .= '<td>'.$t2.'</td>';
                                $a .= '<td>'.$t3.'</td>';
                            }
                        }
                        $a .= '</tr>';
                        $headyears = '';
                        $headcols = '';
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $headyears .= '<th colspan="3">'.static::nyear($fyear[$j]).'</th>';
                            $headcols .= '<th>Actual Amount</th><th>Paid Amount</th><th>Due Amount</th>';
                        }
                        $head = '<thead>
                                    <tr>
                                        <th rowspan="2">S. No</th>
                                        <th rowspan="2">Hall Ticket Number</th>
                                        <th rowspan="2">Name of the student</th>
                                        <th rowspan="2">Admission Type</th>
                                        '.$headyears.'
                                        <th rowspan="2">Total Actual Amount</th>
                                        <th rowspan="2">Total Paid Amount</th>
                                        <th rowspan="2">Total Due Amount</th>
                                    </tr>
                                    <tr>
                                        '.$headcols.'
                                    </tr>
                                </thead>';
                        $body = '<tbody>'; 
                        $body .= $a;
                        $body .= '</tbody>';
                        $table = '
                            <div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm print-this" border="1px">'.$head.'
                                '.$body.'
                                </table>
                            </div>
                        ';
                        $subtable .= $table;
                        $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                    }
                    if($_POST['year'] != "ALL")
                    {
                        $totaldue = 0;
                            $totalpaid = 0;
                            $totalactual = 0;
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            // $count = 0;
                            // for($k=0; $k<sizeof($data); $k++)
                            {
                                if(isset($data[$no[$i]][$_POST['year']]['actualamount']))
                                {
                                    $sno = $i+1;
                                    $a.='<tr>';
                                        $a.='<td>'.$sno.'</td>';
                                        $a.='<td>'.$no[$i].'</td>';
                                        $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                                        $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['actualamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['paidamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['dueamount'].'</td>';
                                        $totalactual = $totalactual+$data[$no[$i]][$_POST['year']]['actualamount'];
                                        $totalpaid = $totalpaid+$data[$no[$i]][$_POST['year']]['paidamount'];
                                        $totaldue = $totaldue+$data[$no[$i]][$_POST['year']]['dueamount'];
                                    $a.='</tr>';
                                    if($i ==sizeof($no)-1)
                                    {
                                        $a.='<tr>';
                                            $a.='<td colspan="3">Total Fee Collection Details</td>';
                                            $a.='<td></td>';
                                            $a.='<td>'.$totalactual.'</td>';
                                            $a.='<td>'.$totalpaid.'</td>';
                                            $a.='<td>'.$totaldue.'</td>';
                                        $a.='</tr>';
                                    }
                                }
                            }
                            
                        }
                        $headyears = '';
                        $headcols = '';
                        $head = '<thead>
                                    <tr>
                                        <th rowspan="2">S. No</th>
                                        <th rowspan="2">Hall Ticket Number</th>
                                        <th rowspan="2">Name of the student</th>
                                        <th rowspan="2">Admission Type</th>
                                        <th rowspan="2">Total Actual Amount</th>
                                        <th rowspan="2">Total Paid Amount</th>
                                        <th rowspan="2">Total Due Amount</th>
                                    </tr>
                                </thead>';
                        $body = '<tbody>'; 
                        $body .= $a;
                        $body .= '</tbody>';
                        $table = '
                            <div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm print-this" 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">Department Wise Consolidated 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">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control">
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="fromyear" id="fromyear" class="form-control">
                                                            <option value="">Starting Year</option>
                                                            ';
                                                            echo $styear;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="squota" id="squota" class="form-control" required>
                                                                <option value="">Select Admission Type</option>
                                                                <option value="1">Convenor Quota</option>
                                                                <option value="2">Spot / Management Quota</option>
                                                                <option value="ALL">All Types</option>
                                                            </select>
                                                        </div>
                                                    </div>  									
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">                                            
                                                            <select name="year" id="year" class="form-control">
                                                                <option value="">Select Year of Course</option>
                                                                <option value="1">First Year</option>
                                                                <option value="2">Second Year</option>
                                                                <option value="3">Third Year</option>
                                                                <option value="4">Fourth Year</option>
                                                                <option value="ALL">All Years</option>
                                                            </select>												
                                                        </div>
                                                    </div>                              
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                                <option value="">Select Fee Type</option>
                                                                '.$feetype.'
                                                            </select>
                                                        </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 coursewiseconsol()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $subtable = '';
            $a = '';
            if(isset($_POST['course']))
            {
                $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND sf.fk_feetype_id='$_POST[feetype]'");
                $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND sf.fk_feetype_id='$_POST[feetype]'");
                if(sizeof($masterdata) > 0)
                {
                    $ht_no = array();
                    $feeyear = array();
                    foreach ($masterdata as $h) {
                        $ht_no[] = $h['no'];
                        $feeyear[] = $h['year'];
                    }
                    $no = array_values(array_unique($ht_no));
                    sort($no);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            for($k=0; $k<sizeof($masterdata); $k++)
                            {
                                if($masterdata[$k]['no'] == $no[$i] && $masterdata[$k]['year'] == $fyear[$j])
                                {
                                    $data[$no[$i]]['quota'] = $masterdata[$k]['squota'];
                                    $data[$no[$i]]['name'] = $masterdata[$k]['name'];
                                    $data[$no[$i]][$fyear[$j]]['actualamount'] = $masterdata[$k]['feeamount'];
                                }
                                if($k == sizeof($masterdata)-1)
                                {
                                    if(!isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['actualamount'] = 0;
                                    }
                                }
                            }
                            $totalamount = 0;
                            if(sizeof($paiddata) > 0)
                            {
                                for($k=0; $k<sizeof($paiddata); $k++)
                                {
                                    if($paiddata[$k]['no'] == $no[$i] && $paiddata[$k]['year'] == $fyear[$j])
                                    {
                                        $totalamount = $totalamount+$paiddata[$k]['amount'];
                                    }
                                    $count = sizeof($paiddata)-1;
                                    if($k == $count && !isset($data[$no[$i]][$fyear[$j]]['paidamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['paidamount'] = $totalamount;
                                        if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                        {
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = $data[$no[$i]][$fyear[$j]]['actualamount']-$totalamount;
                                        }
                                        else
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                        if($data[$no[$i]][$fyear[$j]]['actualamount'] == 0)
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                            }
                        }
                    }
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        $count = 0;
                        $totaldue = 0;
                        $totalpaid = 0;
                        $totalactual = 0;
                        $sno = $i+1;
                        $a.='<tr>';
                        $a.='<td>'.$sno.'</td>';
                        $a.='<td>'.$no[$i].'</td>';
                        $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                        $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                        for($k=0; $k<sizeof($data); $k++)
                        {
                            for($j=0; $j<sizeof($fyear); $j++)
                            {
                                if($count < sizeof($fyear))
                                {
                                    if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['actualamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['paidamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['dueamount'].'</td>';
                                        $count++;
                                        $totalactual = $totalactual+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                        $totalpaid = $totalpaid+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                        $totaldue = $totaldue+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                    }
                                }
                            }
                        }
                        $a.='<td>'.$totalactual.'</td>';
                        $a.='<td>'.$totalpaid.'</td>';
                        $a.='<td>'.$totaldue.'</td>';
                        $a.='</tr>';
                    }
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $actualfee = 0;
                        $paidfee = 0;
                        $duefee = 0;
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            for($k=0; $k<sizeof($data); $k++)
                            {
                                $actualfee = $actualfee+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                $paidfee = $paidfee+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                $duefee = $duefee+$data[$no[$i]][$fyear[$j]]['dueamount'];
                            }
                        }
                        $afee[$fyear[$j]] = $actualfee/sizeof($no);
                        $pfee[$fyear[$j]] = $paidfee/sizeof($no);
                        $dfee[$fyear[$j]] = $duefee/sizeof($no);
                    }
                    $a .= '<tr>';
                    $a .= '<td colspan="3">Total Fee Collection Details</td>';
                    $t1 = 0;
                    $t2 = 0;
                    $t3 = 0;
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $t1 = $t1+$afee[$fyear[$j]];
                        $t2 = $t2+$pfee[$fyear[$j]];
                        $t3 = $t3+$dfee[$fyear[$j]];
                        $a .= '<td>'.$afee[$fyear[$j]].'</td>';
                        $a .= '<td>'.$pfee[$fyear[$j]].'</td>';
                        $a .= '<td>'.$dfee[$fyear[$j]].'</td>';
                        if($j == sizeof($fyear)-1)
                        {
                            $a .= '<td>'.$t1.'</td>';
                            $a .= '<td>'.$t2.'</td>';
                            $a .= '<td>'.$t3.'</td>';
                        }
                    }
                    $a .= '</tr>';
                    // echo json_encode($dfee);
                    $headyears = '';
                    $headcols = '';
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $headyears .= '<th colspan="3">'.static::nyear($fyear[$j]).'</th>';
                        $headcols .= '<th>Actual Amount</th><th>Paid Amount</th><th>Due Amount</th>';
                    }
                    $head = '<thead>
                                <tr>
                                    <th rowspan="2">S. No</th>
                                    <th rowspan="2">Admission Number</th>
                                    <th rowspan="2">Name of the student</th>
                                    <th rowspan="2">Admission Type</th>
                                    '.$headyears.'
                                    <th rowspan="2">Total Actual Amount</th>
                                    <th rowspan="2">Total Paid Amount</th>
                                    <th rowspan="2">Total Due Amount</th>
                                </tr>
                                <tr>
                                    '.$headcols.'
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $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">Course Wise Detailed 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">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">
                                                            <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                                <option value="">Select Fee Type</option>
                                                                '.$feetype.'
                                                            </select>
                                                        </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 deptwiseconsolactive()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 ||  $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $subtable = '';
            $a = '';
            if(isset($_POST['course']))
            {
                if($_POST['squota'] == 1)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM  stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                    $paiddata = Homem::getdata("SELECT * FROM  stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                }
                if($_POST['squota'] == 2)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                
                }
                if($_POST['squota'] == 'ALL')
                {
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' OR um.tc_given='')");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                
                }
                if(sizeof($masterdata) > 0)
                {
                    $ht_no = array();
                    $feeyear = array();
                    foreach ($masterdata as $h) {
                        $ht_no[] = $h['no'];
                        $feeyear[] = $h['year'];
                    }
                    $no = array_values(array_unique($ht_no));
                    sort($no);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            for($k=0; $k<sizeof($masterdata); $k++)
                            {
                                if($masterdata[$k]['no'] == $no[$i] && $masterdata[$k]['year'] == $fyear[$j])
                                {
                                    $data[$no[$i]]['name'] = $masterdata[$k]['name'];
                                    $data[$no[$i]]['quota'] = $masterdata[$k]['squota'];
                                    $data[$no[$i]][$fyear[$j]]['actualamount'] = $masterdata[$k]['feeamount'];
                                }
                                if($k == sizeof($masterdata)-1)
                                {
                                    if(!isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['actualamount'] = 0;
                                    }
                                }
                            }
                            $totalamount = 0;
                            if(sizeof($paiddata) > 0)
                            {
                                for($k=0; $k<sizeof($paiddata); $k++)
                                {
                                    if($paiddata[$k]['no'] == $no[$i] && $paiddata[$k]['year'] == $fyear[$j])
                                    {
                                        $totalamount = $totalamount+$paiddata[$k]['amount'];
                                    }
                                    $count = sizeof($paiddata)-1;
                                    if($k == $count && !isset($data[$no[$i]][$fyear[$j]]['paidamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['paidamount'] = $totalamount;
                                        if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                        {
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = $data[$no[$i]][$fyear[$j]]['actualamount']-$totalamount;
                                        }
                                        else
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                        if($data[$no[$i]][$fyear[$j]]['actualamount'] == 0)
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                            }
                        }
                    }
                    if($_POST['year'] == "ALL")
                    {
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            $count = 0;
                            $totaldue = 0;
                            $totalpaid = 0;
                            $totalactual = 0;
                            $sno = $i+1;
                            $a.='<tr>';
                            $a.='<td>'.$sno.'</td>';
                            $a.='<td>'.$no[$i].'</td>';
                            $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                            $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                            for($k=0; $k<sizeof($data); $k++)
                            {
                                for($j=0; $j<sizeof($fyear); $j++)
                                {
                                    if($count < sizeof($fyear))
                                    {
                                        if($_POST['year'] == "ALL")
                                        {
                                            if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                            {
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['actualamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['paidamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['dueamount'].'</td>';
                                                $count++;
                                                $totalactual = $totalactual+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                                $totalpaid = $totalpaid+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                                $totaldue = $totaldue+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                            }
                                        }
                                        
                                    }
                                }
                            }
                            $a.='<td>'.$totalactual.'</td>';
                            $a.='<td>'.$totalpaid.'</td>';
                            $a.='<td>'.$totaldue.'</td>';
                            $a.='</tr>';
                        }
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $actualfee = 0;
                            $paidfee = 0;
                            $duefee = 0;
                            for($i=0; $i<sizeof($no); $i++)
                            {
                                for($k=0; $k<sizeof($data); $k++)
                                {
                                    $actualfee = $actualfee+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                    $paidfee = $paidfee+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                    $duefee = $duefee+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                }
                            }
                            $afee[$fyear[$j]] = $actualfee/sizeof($no);
                            $pfee[$fyear[$j]] = $paidfee/sizeof($no);
                            $dfee[$fyear[$j]] = $duefee/sizeof($no);
                        }
                        $a .= '<tr>';
                        $a .= '<td colspan="3">Total Fee Collection Details</td>';
                        $a .= '<td></td>';
                        $t1 = 0;
                        $t2 = 0;
                        $t3 = 0;
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $t1 = $t1+$afee[$fyear[$j]];
                            $t2 = $t2+$pfee[$fyear[$j]];
                            $t3 = $t3+$dfee[$fyear[$j]];
                            $a .= '<td>'.$afee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$pfee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$dfee[$fyear[$j]].'</td>';
                            if($j == sizeof($fyear)-1)
                            {
                                $a .= '<td>'.$t1.'</td>';
                                $a .= '<td>'.$t2.'</td>';
                                $a .= '<td>'.$t3.'</td>';
                            }
                        }
                        $a .= '</tr>';
                        $headyears = '';
                        $headcols = '';
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $headyears .= '<th colspan="3">'.static::nyear($fyear[$j]).'</th>';
                            $headcols .= '<th>Actual Amount</th><th>Paid Amount</th><th>Due Amount</th>';
                        }
                        $head = '<thead>
                                    <tr>
                                        <th rowspan="2">S. No</th>
                                        <th rowspan="2">Hall Ticket Number</th>
                                        <th rowspan="2">Name of the student</th>
                                        <th rowspan="2">Admission Type</th>
                                        '.$headyears.'
                                        <th rowspan="2">Total Actual Amount</th>
                                        <th rowspan="2">Total Paid Amount</th>
                                        <th rowspan="2">Total Due Amount</th>
                                    </tr>
                                    <tr>
                                        '.$headcols.'
                                    </tr>
                                </thead>';
                        $body = '<tbody>'; 
                        $body .= $a;
                        $body .= '</tbody>';
                        $table = '
                            <div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm print-this" border="1px">'.$head.'
                                '.$body.'
                                </table>
                            </div>
                        ';
                        $subtable .= $table;
                        $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                    }
                    if($_POST['year'] != "ALL")
                    {
                        $totaldue = 0;
                            $totalpaid = 0;
                            $totalactual = 0;
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            // $count = 0;
                            // for($k=0; $k<sizeof($data); $k++)
                            {
                                if(isset($data[$no[$i]][$_POST['year']]['actualamount']))
                                {
                                    $sno = $i+1;
                                    $a.='<tr>';
                                        $a.='<td>'.$sno.'</td>';
                                        $a.='<td>'.$no[$i].'</td>';
                                        $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                                        $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['actualamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['paidamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$_POST['year']]['dueamount'].'</td>';
                                        $totalactual = $totalactual+$data[$no[$i]][$_POST['year']]['actualamount'];
                                        $totalpaid = $totalpaid+$data[$no[$i]][$_POST['year']]['paidamount'];
                                        $totaldue = $totaldue+$data[$no[$i]][$_POST['year']]['dueamount'];
                                    $a.='</tr>';
                                    if($i ==sizeof($no)-1)
                                    {
                                        $a.='<tr>';
                                            $a.='<td colspan="3">Total Fee Collection Details</td>';
                                            $a.='<td></td>';
                                            $a.='<td>'.$totalactual.'</td>';
                                            $a.='<td>'.$totalpaid.'</td>';
                                            $a.='<td>'.$totaldue.'</td>';
                                        $a.='</tr>';
                                    }
                                }
                            }
                            
                        }
                        $headyears = '';
                        $headcols = '';
                        $head = '<thead>
                                    <tr>
                                        <th rowspan="2">S. No</th>
                                        <th rowspan="2">Hall Ticket Number</th>
                                        <th rowspan="2">Name of the student</th>
                                        <th rowspan="2">Admission Type</th>
                                        <th rowspan="2">Total Actual Amount</th>
                                        <th rowspan="2">Total Paid Amount</th>
                                        <th rowspan="2">Total Due Amount</th>
                                    </tr>
                                </thead>';
                        $body = '<tbody>'; 
                        $body .= $a;
                        $body .= '</tbody>';
                        $table = '
                            <div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm print-this" 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">Department Wise Consolidated 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">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="department" id="department" class="form-control">
                                                            <option value="">Department</option>
                                                            ';
                                                            echo $dept;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="fromyear" id="fromyear" class="form-control">
                                                            <option value="">Starting Year</option>
                                                            ';
                                                            echo $styear;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>  
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select name="squota" id="squota" class="form-control" required>
                                                                <option value="">Select Admission Type</option>
                                                                <option value="1">Convenor Quota</option>
                                                                <option value="2">Spot / Management Quota</option>
                                                                <option value="ALL">All Types</option>
                                                            </select>
                                                        </div>
                                                    </div>  									
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">                                            
                                                            <select name="year" id="year" class="form-control">
                                                                <option value="">Select Year of Course</option>
                                                                <option value="1">First Year</option>
                                                                <option value="2">Second Year</option>
                                                                <option value="3">Third Year</option>
                                                                <option value="4">Fourth Year</option>
                                                                <option value="ALL">All Years</option>
                                                            </select>												
                                                        </div>
                                                    </div>                              
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                                <option value="">Select Fee Type</option>
                                                                '.$feetype.'
                                                            </select>
                                                        </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 coursewiseconsolactive()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $subtable = '';
            $a = '';
            if(isset($_POST['course']))
            {
                $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued='' AND um.tc_given='')");
                if(sizeof($masterdata) > 0)
                {
                    $ht_no = array();
                    $feeyear = array();
                    foreach ($masterdata as $h) {
                        $ht_no[] = $h['no'];
                        $feeyear[] = $h['year'];
                    }
                    $no = array_values(array_unique($ht_no));
                    sort($no);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            for($k=0; $k<sizeof($masterdata); $k++)
                            {
                                if($masterdata[$k]['no'] == $no[$i] && $masterdata[$k]['year'] == $fyear[$j])
                                {
                                    $data[$no[$i]]['quota'] = $masterdata[$k]['squota'];
                                    $data[$no[$i]]['name'] = $masterdata[$k]['name'];
                                    $data[$no[$i]][$fyear[$j]]['actualamount'] = $masterdata[$k]['feeamount'];
                                }
                                if($k == sizeof($masterdata)-1)
                                {
                                    if(!isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['actualamount'] = 0;
                                    }
                                }
                            }
                            $totalamount = 0;
                            if(sizeof($paiddata) > 0)
                            {
                                for($k=0; $k<sizeof($paiddata); $k++)
                                {
                                    if($paiddata[$k]['no'] == $no[$i] && $paiddata[$k]['year'] == $fyear[$j])
                                    {
                                        $totalamount = $totalamount+$paiddata[$k]['amount'];
                                    }
                                    $count = sizeof($paiddata)-1;
                                    if($k == $count && !isset($data[$no[$i]][$fyear[$j]]['paidamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['paidamount'] = $totalamount;
                                        if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                        {
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = $data[$no[$i]][$fyear[$j]]['actualamount']-$totalamount;
                                        }
                                        else
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                        if($data[$no[$i]][$fyear[$j]]['actualamount'] == 0)
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                            }
                        }
                    }
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        $count = 0;
                        $totaldue = 0;
                        $totalpaid = 0;
                        $totalactual = 0;
                        $sno = $i+1;
                        $a.='<tr>';
                        $a.='<td>'.$sno.'</td>';
                        $a.='<td>'.$no[$i].'</td>';
                        $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                        $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                        for($k=0; $k<sizeof($data); $k++)
                        {
                            for($j=0; $j<sizeof($fyear); $j++)
                            {
                                if($count < sizeof($fyear))
                                {
                                    if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['actualamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['paidamount'].'</td>';
                                        $a.='<td>'.$data[$no[$i]][$fyear[$j]]['dueamount'].'</td>';
                                        $count++;
                                        $totalactual = $totalactual+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                        $totalpaid = $totalpaid+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                        $totaldue = $totaldue+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                    }
                                }
                            }
                        }
                        $a.='<td>'.$totalactual.'</td>';
                        $a.='<td>'.$totalpaid.'</td>';
                        $a.='<td>'.$totaldue.'</td>';
                        $a.='</tr>';
                    }
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $actualfee = 0;
                        $paidfee = 0;
                        $duefee = 0;
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            for($k=0; $k<sizeof($data); $k++)
                            {
                                $actualfee = $actualfee+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                $paidfee = $paidfee+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                $duefee = $duefee+$data[$no[$i]][$fyear[$j]]['dueamount'];
                            }
                        }
                        $afee[$fyear[$j]] = $actualfee/sizeof($no);
                        $pfee[$fyear[$j]] = $paidfee/sizeof($no);
                        $dfee[$fyear[$j]] = $duefee/sizeof($no);
                    }
                    $a .= '<tr>';
                    $a .= '<td colspan="3">Total Fee Collection Details</td>';
                    $t1 = 0;
                    $t2 = 0;
                    $t3 = 0;
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $t1 = $t1+$afee[$fyear[$j]];
                        $t2 = $t2+$pfee[$fyear[$j]];
                        $t3 = $t3+$dfee[$fyear[$j]];
                        $a .= '<td>'.$afee[$fyear[$j]].'</td>';
                        $a .= '<td>'.$pfee[$fyear[$j]].'</td>';
                        $a .= '<td>'.$dfee[$fyear[$j]].'</td>';
                        if($j == sizeof($fyear)-1)
                        {
                            $a .= '<td>'.$t1.'</td>';
                            $a .= '<td>'.$t2.'</td>';
                            $a .= '<td>'.$t3.'</td>';
                        }
                    }
                    $a .= '</tr>';
                    // echo json_encode($dfee);
                    $headyears = '';
                    $headcols = '';
                    for($j=0; $j<sizeof($fyear); $j++)
                    {
                        $headyears .= '<th colspan="3">'.static::nyear($fyear[$j]).'</th>';
                        $headcols .= '<th>Actual Amount</th><th>Paid Amount</th><th>Due Amount</th>';
                    }
                    $head = '<thead>
                                <tr>
                                    <th rowspan="2">S. No</th>
                                    <th rowspan="2">Admission Number</th>
                                    <th rowspan="2">Name of the student</th>
                                    <th rowspan="2">Admission Type</th>
                                    '.$headyears.'
                                    <th rowspan="2">Total Actual Amount</th>
                                    <th rowspan="2">Total Paid Amount</th>
                                    <th rowspan="2">Total Due Amount</th>
                                </tr>
                                <tr>
                                    '.$headcols.'
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $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">Course Wise Detailed 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">                                            
                                                            <select name="course" id="course" class="form-control">
                                                            <option value="">Course</option>
                                                            ';
                                                            echo $course;
                                                            echo '
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">
                                                            <select name="feetype" id="feetype" class="form-control" onchange="getdueamount()" required>
                                                                <option value="">Select Fee Type</option>
                                                                '.$feetype.'
                                                            </select>
                                                        </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 deptwiseconsolinactive()
    {
        if($_SESSION['user_role'] == 4 || $_SESSION['user_role'] == 6 ||  $_SESSION['user_role'] == 5)
        {
            $course = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_name_master`"), 'id', 'code');
            $dept = Inputs::optionsdb(Homem::getdata("SELECT * FROM `degree_dept_master`"), 'id', 'name');
            $styear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT fromyear FROM `user_master` where `fromyear`!='' AND `user_role`='3' ORDER BY `fromyear` ASC"), 'fromyear', 'fromyear');
            $enyear = Inputs::optionsdb(Homem::getdata("SELECT DISTINCT toyear FROM `user_master` where `toyear`!='' AND `user_role`='3' ORDER BY `toyear` ASC"), 'toyear', 'toyear');
            $feetype = Inputs::optionsdb(Homem::getdata("SELECT * FROM `fee_types`"), 'f_id', 'f_name');
            $subtable = '';
            $a = '';
            if(isset($_POST['course']))
            {
                if($_POST['squota'] == 1)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM  stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                    $paiddata = Homem::getdata("SELECT * FROM  stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                }
                if($_POST['squota'] == 2)
                {
                    $_POST['squota'] = 'C';
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND um.squota!='$_POST[squota]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                
                }
                if($_POST['squota'] == 'ALL')
                {
                    $masterdata = Homem::getdata("SELECT * FROM stdnt_feemaster sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                    $paiddata = Homem::getdata("SELECT * FROM stdnt_normalfee sf JOIN user_master um ON um.id=sf.no WHERE um.fk_course_id='$_POST[course]' AND um.fk_dept_id='$_POST[department]' AND um.fromyear='$_POST[fromyear]' AND sf.fk_feetype_id='$_POST[feetype]' AND (um.discontinued!='' AND um.tc_given!='')");
                
                }
                if(sizeof($masterdata) > 0)
                {
                    $ht_no = array();
                    $feeyear = array();
                    foreach ($masterdata as $h) {
                        $ht_no[] = $h['no'];
                        $feeyear[] = $h['year'];
                    }
                    $no = array_values(array_unique($ht_no));
                    sort($no);
                    $fyear = array_values(array_unique($feeyear));
                    sort($fyear);
                    for($i=0; $i<sizeof($no); $i++)
                    {
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            for($k=0; $k<sizeof($masterdata); $k++)
                            {
                                if($masterdata[$k]['no'] == $no[$i] && $masterdata[$k]['year'] == $fyear[$j])
                                {
                                    $data[$no[$i]]['name'] = $masterdata[$k]['name'];
                                    $data[$no[$i]]['quota'] = $masterdata[$k]['squota'];
                                    $data[$no[$i]][$fyear[$j]]['actualamount'] = $masterdata[$k]['feeamount'];
                                }
                                if($k == sizeof($masterdata)-1)
                                {
                                    if(!isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['actualamount'] = 0;
                                    }
                                }
                            }
                            $totalamount = 0;
                            if(sizeof($paiddata) > 0)
                            {
                                for($k=0; $k<sizeof($paiddata); $k++)
                                {
                                    if($paiddata[$k]['no'] == $no[$i] && $paiddata[$k]['year'] == $fyear[$j])
                                    {
                                        $totalamount = $totalamount+$paiddata[$k]['amount'];
                                    }
                                    $count = sizeof($paiddata)-1;
                                    if($k == $count && !isset($data[$no[$i]][$fyear[$j]]['paidamount']))
                                    {
                                        $data[$no[$i]][$fyear[$j]]['paidamount'] = $totalamount;
                                        if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                        {
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = $data[$no[$i]][$fyear[$j]]['actualamount']-$totalamount;
                                        }
                                        else
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                        if($data[$no[$i]][$fyear[$j]]['actualamount'] == 0)
                                        {
                                            $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                            $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                $data[$no[$i]][$fyear[$j]]['paidamount'] = 0;
                                $data[$no[$i]][$fyear[$j]]['dueamount'] = 0;
                            }
                        }
                    }
                }
                    if($_POST['year'] == "ALL")
                    {
                        for($i=0; $i<sizeof($no); $i++)
                        {
                            $count = 0;
                            $totaldue = 0;
                            $totalpaid = 0;
                            $totalactual = 0;
                            $sno = $i+1;
                            $a.='<tr>';
                            $a.='<td>'.$sno.'</td>';
                            $a.='<td>'.$no[$i].'</td>';
                            $a.='<td>'.$data[$no[$i]]['name'].'</td>';
                            $a.='<td>'.$data[$no[$i]]['quota'].'</td>';
                            for($k=0; $k<sizeof($data); $k++)
                            {
                                for($j=0; $j<sizeof($fyear); $j++)
                                {
                                    if($count < sizeof($fyear))
                                    {
                                        if($_POST['year'] == "ALL")
                                        {
                                            if(isset($data[$no[$i]][$fyear[$j]]['actualamount']))
                                            {
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['actualamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['paidamount'].'</td>';
                                                $a.='<td>'.$data[$no[$i]][$fyear[$j]]['dueamount'].'</td>';
                                                $count++;
                                                $totalactual = $totalactual+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                                $totalpaid = $totalpaid+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                                $totaldue = $totaldue+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                            }
                                        }
                                        
                                    }
                                }
                            }
                            $a.='<td>'.$totalactual.'</td>';
                            $a.='<td>'.$totalpaid.'</td>';
                            $a.='<td>'.$totaldue.'</td>';
                            $a.='</tr>';
                        }
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $actualfee = 0;
                            $paidfee = 0;
                            $duefee = 0;
                            for($i=0; $i<sizeof($no); $i++)
                            {
                                for($k=0; $k<sizeof($data); $k++)
                                {
                                    $actualfee = $actualfee+$data[$no[$i]][$fyear[$j]]['actualamount'];
                                    $paidfee = $paidfee+$data[$no[$i]][$fyear[$j]]['paidamount'];
                                    $duefee = $duefee+$data[$no[$i]][$fyear[$j]]['dueamount'];
                                }
                            }
                            $afee[$fyear[$j]] = $actualfee/sizeof($no);
                            $pfee[$fyear[$j]] = $paidfee/sizeof($no);
                            $dfee[$fyear[$j]] = $duefee/sizeof($no);
                        }
                        $a .= '<tr>';
                        $a .= '<td colspan="3">Total Fee Collection Details</td>';
                        $a .= '<td></td>';
                        $t1 = 0;
                        $t2 = 0;
                        $t3 = 0;
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $t1 = $t1+$afee[$fyear[$j]];
                            $t2 = $t2+$pfee[$fyear[$j]];
                            $t3 = $t3+$dfee[$fyear[$j]];
                            $a .= '<td>'.$afee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$pfee[$fyear[$j]].'</td>';
                            $a .= '<td>'.$dfee[$fyear[$j]].'</td>';
                            if($j == sizeof($fyear)-1)
                            {
                                $a .= '<td>'.$t1.'</td>';
                                $a .= '<td>'.$t2.'</td>';
                                $a .= '<td>'.$t3.'</td>';
                            }
                        }
                        $a .= '</tr>';
                        $headyears = '';
                        $headcols = '';
                        for($j=0; $j<sizeof($fyear); $j++)
                        {
                            $headyears .= '<th colspan="3">'.static::nyear($fyear[$j]).'</th>';
                            $headcols .= '<th>Actual Amount</th><th>Paid Amount</th><th>Due Amount</th>';
                        }
}
            }
        }
    }
}