<?php require "_header.php"; ?>
<script language="javascript" type="text/javascript">
    // document.getElementById("main-content").style.display = 'none';
</script>

<div id="main-report" align="center">

    <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <style>
    .table td.b
     {
        border: 1px solid black;
        border-top: 1px solid black;
        border-bottom: 1px solid black;
     }
     .table tbody + tbody
     {
        border-top: none;
     }
     .col
     {
        font-weight: 100;
     }

</style>
    </head>
    <h3>
        Vedant Science College </h3>
    <h5>
        At.po. Ta.Lunawada,Dist.Mahisagar,Santrampur Road Pin.Cod. 389230</h5>
    <h4>Student Full Fees Debit Report </h4>
    <br>
    
    <br>


    <?php
    
    $adm_year = '';

    $branch_id     = Escape($_REQUEST['branch_hidden']);
    $semester_id  = $_REQUEST['semester_hidden'];

    $div_id       = Escape($_REQUEST['division_id']);
    $student_id   = Escape($_REQUEST['student_hidden']);

    $allsem    = Escape($_REQUEST['allsem']);
    $regular    = Escape($_REQUEST['regular']);
    $branch_disp     = Escape($_REQUEST['branch_disp']);
    $semester_disp  = Escape($_REQUEST['semester_disp']);
    $show_mobile_no = Escape($_REQUEST['show_mobile_no']);
    $allsem = Escape($_REQUEST['allsem']);
    if ($branch_id == "" && $semester_id == "") { ?>
        <script language="javascript" type="text/javascript">
            location.href = 'report-fees-dueamt.php';
        </script><?php
                } elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
                    if ($student_id != 0  || $student_id  != '') {
                        $adm_year =  getAdmYear($student_id);
                    }
                    ob_start();

                    ?>
                    <h5 class="text-left" style="margin-right: 70px;">BRANCH:
                     <?php echo ($branch_disp ? $branch_disp:"-"); ?> &nbsp;&nbsp;&nbsp;|
                    SEM:
                      <?php echo ($semester_disp ? $semester_disp:"All"); ?>
                      </h5> 
                    <br>
        <table class="table border border-dark">
           
                <tr class=" border border-dark" >
                    <td scope="col" class="b" style="font-weight:bold;">Sr No.</td>
                    <td scope="col" class="b" style="font-weight:bold;">GTU Reg No</td>
                    <td scope="col" class="b" style="font-weight:bold;">Student Name</td>
                    <td scope="col" class="b" style="font-weight:bold;"> Semester</td>
                    <td scope="col" class="b" style="font-weight:bold;">Total</td>
                    <td scope="col" class="b" style="font-weight:bold;">Paid</td>
                    <td scope="col" class="b" style="font-weight:bold;">Due</td>
                </tr>
            <tbody>
                <?php  

                    $objStudentMgmt = new StudentMgmt();
                    $objStudentMgmt->branch_id = $branch_id;
                    $objStudentMgmt->semester_id = $semester_id;
                    $objStudentMgmt->div_id = $div_id;
                    $objStudentMgmt->student_id = $student_id;

                  
                  
                    $res_student = $objStudentMgmt->getCurrentYearStudent();
                    $cou_student = dbRows($res_student);
                    if ($cou_student > 0) {
                        $i=1;
                        while ($row_student = dbArray($res_student)) {

                            $student_id = $row_student['student_id'];
                            $student_name = $row_student['student_name'];
                            $student_gturegno = $row_student['student_gturegno'];
                           

                            $sem_ary=array();
                            $year_arr=array();
                            $all_sem_and_year = $objStudentMgmt-> getStudentAllSemAndYear($student_id);
                            $cou=dbRows($all_sem_and_year);
                            if($cou>0)
                            {
                                while($row=dbArray($all_sem_and_year))
                                {
                                    
                                    $sem_ary[]=$row['cur_semesterid'];
                                    $year_arr[]=$row['year_id'];
                                }
                            }
                            $first_sem_index=$sem_ary[0];

                            $cur_sem_index=count($sem_ary)-1;
                          
                            $cur_semesterid=$sem_ary[ $cur_sem_index];

                            
                            //  print_r($sem_ary);
                            //  print_r($year_arr);
                            //  exit;
                             $sem_year = array_combine($sem_ary, $year_arr);
                            //  print_r($sem_year);
                            //  exit;
                            // i want to fetch $sem_year array's index and value
                            //index_value=$sem_str
                            //index's value=$year_Str
                            $total_fee=0;

                            foreach($sem_year as $sem_str => $year_str)
                            {
                               
                                $total_fee += $objStudentMgmt->TotalFee($branch_id,$sem_str,$year_str);
                            }

                            

                             $paid_fee = $objStudentMgmt->PaidFee($student_id);
                              
                             $due_fee = $total_fee - $paid_fee;
                            ?>
                            <tr>
                            <td class="b"> <?php echo $i; ?></td>

                                <td class="b"><?php if($student_gturegno == "")
                                {
                                    // echo $student_id;
                                    echo "-";
                                    

                                }
                                else
                                {
                                    echo $student_gturegno;
                                }
                                 ?></td>
                                <td class="b"><?php echo $student_name; ?></td>
                                <td class="b"><?php echo  "Sem:".$first_sem_index." to ".$cur_semesterid; ?></td>
                                <td class="b"><?php echo $total_fee; ?></td>
                                <td class="b"><?php if($paid_fee == "")
                                {
                                    echo 0;
                                }
                                else
                                {
                                 echo $paid_fee; 
                                }?></td>
                                <td class="b" ><?php echo $due_fee; ?></td>
                            </tr>
<?php


                     $i++;
                        }
                    }


                ?>
            </tbody>
        </table>
    <?php
                }
