<?php require "_header.php";
error_reporting(1); ?>
<script language="javascript" type="text/javascript">
    document.getElementById("main-content").style.display = 'none';
</script>
<style type="text/css">
    .table-report {
        font-family: Verdana, Geneva, sans-serif;
        font-size: 12px;
        text-align: left;
        border-right: 0px none;
        border-bottom: 0px none;
    }

    .table-report-inner {
        font-family: Verdana, Geneva, sans-serif;
        font-size: 12px;
    }

    .table-report tr {
        padding: 2px 2px 2px 2px;
    }

    .table-report td {
        padding: 2px 2px 2px 2px;
        border-top: 0px none;
        border-left: 0px none;
    }

    .table-report th {
        padding: 2px 2px 2px 2px;
        font-weight: bold;
        text-align: left;
        border-top: 0px none;
        border-left: 0px none;
    }

    .college_name {
        font-family: QTAbbie;
        font-size: 22px;
        font-weight: bold;
        padding: 2px 2px 2px 2px;
        text-align: center;
    }

    .college_address {
        font-family: Tahoma, Geneva, sans-serif;
        font-size: 11px;
        text-align: center;
        padding: 2px 2px 2px 2px;
    }

    .break {
        page-break-before: always;
    }
</style>
<div id="main-report">
    <?php
    if ($_REQUEST['branch_hidden'] == "") {
        ?>
        <script language="javascript" type="text/javascript">
            location.href = 'student_facility.php';
        </script>
        <?php
    } elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
        ob_start();
        $branch_id = Escape($_REQUEST['branch_hidden']);
        $branchyear_id = Escape($_REQUEST['branchyear_hidden']);
        $year_id = Escape($_REQUEST['year_hidden']);
        $semester_id = Escape($_REQUEST['semester_hidden']);
        $student_id = Escape($_REQUEST['student_hidden']);


        $branch_name = Escape($_REQUEST['branch_disp']);
        $year_name = Escape($_REQUEST['year_disp']);
        $branchyear_name = Escape($_REQUEST['branchyear_disp']);
        $semester_name = Escape($_REQUEST['semester_disp']);
        $student_name = Escape($_REQUEST['student_disp']);




        $condition = "";
        if ($branch_id != "" && $branch_id != "All") {
            $condition .= " AND sd.cur_branchid = " . $branch_id;
        }
        if ($semester_id != "" && $semester_id != "undefined" && $semester_id != 0) {
            $condition .= " AND sd.cur_semesterid = " . $semester_id;
        }

        if ($year_id != "" && $year_id != "undefined") {
            $condition .= " AND sd.year_id = '" . $year_id . "'";
        }

        if ($branchyear_id != "" && $branchyear_id != "undefined") {
            $condition .= " AND sd.cur_branchyearid = '" . $branchyear_id . "'";
        }

        if ($student_id != "" && $student_id != 'undefined') {
            $condition .= " AND sm.student_id = '" . $student_id . "' ";
        }

        $condition .= " ORDER BY transport_id DESC";

        $objStudentDetailMgmt = new StudentDetailMgmt;
        $objStudentFeesRecMgmt = new StudentFeesRecMgmt;
        $RES_STUDENT = $objStudentDetailMgmt->getFacilityData(0, 0, $condition);
        if (dbRows($RES_STUDENT) > 0) {

            ?>
            <div style="display: inline-block; vertical-align: middle;">
                <b style="font-size: 30px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
                <?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
                Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>&nbsp;&nbsp;
                Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
            </div>

            <center>
                <h4>Student Facility Report</h4>
            </center>

            <table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td colspan="10">
                        <table style="width: 100%; border-collapse: collapse;">
                            <tr>
                                <td width="10%"><b>Name of the Student:</td>
                                <td width="60%"><?php echo $student_name; ?></td>
                            </tr>
                            <tr>
                                <td width="10%"><b>Course:</b></td>
                                <td width="60%"><?php echo $branch_name; ?></td>
                            </tr>
                            <tr>
                                <?php if ($_REQUEST['semester_hidden'] != "") { ?>
                                    <td width="10%"><b>Semester:</b></td>
                                    <td width="60%">
                                        <?php echo $semester_name; ?>
                                    </td>
                                    <?php
                                }
                                ?>
                            </tr>
                            <tr>
                                <?php if ($_REQUEST['branchyear_hidden'] != "") { ?>
                                    <td width="10%"><b>Course Year:</b></td>
                                    <td width="60%">
                                        <?php echo $branchyear_name; ?>
                                    </td>
                                    <?php
                                }
                                ?>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>

                    <th style="text-align:center;" width="5%">Sr</th>
                    <th style="text-align:center;" width="5%">Hostel/Transport</th>
                    <th style="text-align:center;" width="5%">From</th>
                    <th style="text-align:center;" width="5%">To</th>
                    <th style="text-align:center;" width="5%">Total Fees Amount</th>
                </tr>
                <?php
                $i = 1;
                $temp = "";
                $temp1 = "";
                $temp2 = "";

                while ($REC_STUDENT = dbArray($RES_STUDENT)) {
                    $date = str_replace('/', '-', $REC_STUDENT['from_date']);
                    $date1 = str_replace("/", "-", $REC_STUDENT['to_date']);
                    $condition = "AND frm.receipt_date BETWEEN '" . date("Y-m-d", strtotime($date)) . "' AND '" . ($REC_STUDENT['to_date'] != "00-00-0000" ? date("Y-m-d", strtotime($date1)) : date("Y-m-d")) . "' AND frm.student_id = {$REC_STUDENT['student_id']} AND frd.head_id = {$REC_STUDENT['head_id']}";
                    $out = $objStudentFeesRecMgmt->getfeesdueamt3($condition);
                    $array = dbArray($out);
                    if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['branchyear_name'] != $temp1) || ($REC_STUDENT['semester_name'] != $temp2)) {
                        $temp = $REC_STUDENT['branch_name'];
                        $temp1 = $REC_STUDENT['branchyear_name'];
                        $temp2 = $REC_STUDENT['semester_name'];
                        $i = 1;
                        ?>
                        <?php
                    } ?>
                    <tr>


                        <td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
                        <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['Facility']; ?></td>
                        <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['from_date']; ?></td>
                        <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['to_date']; ?></td>
                        <td style="text-align:center;">&nbsp;<?php echo $array['receive_amt']; ?></td>
                    </tr>
                    <?php
                }
                ?>
            </table>
            <?php
        } else {
            echo "NO DATA FOUND!";
        }
        ?>
        <?php
        $HtmlCode = ob_get_contents();
        ob_end_flush();
        $header_row_string = "";
        $HtmlUrl = "studentlist-report.html";
        $HtmlPath = "report/" . $HtmlUrl;
        createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, false);
        ?>
        <br />
        <form name="frm" id="frm" action="" method="post">
            <input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl; ?>" />
            <input type="button" name="btnPrint" id="btnPrint" value="Print" onClick="SetPageAction('PRINT');" />
            <input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');" />
            <input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');" />
            <input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');" />
            <input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');" />
        </form>
        <script language="javascript" type="text/javascript">
            function SetPageAction(varAction) {
                if (varAction == "PRINT") {
                    document.frm.action = "print/create-print.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if (varAction == "PDF") {
                    document.frm.action = "convertpdf/create-pdf.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if (varAction == "HTML") {
                    document.frm.action = "<?php echo $HtmlPath; ?>";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if (varAction == "WORD") {
                    document.frm.action = "convertword/create-word.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
                else if (varAction == "Excel") {
                    document.frm.action = "convertword/create-excel.php";
                    document.frm.target = "_blank";
                    document.frm.submit();
                }
            }
        </script>
    <?php } ?>
</div>
<?php
require "_footer.php";
?>