<?php

include_once '../db_connect/db.php';
//get current session
 $user_id = $_SESSION['student_id'];
 //$session = get_current_session($id = 1);
 $session = 6;

 ?>
    <div style="height:20px; displat:block;"></div>

    <ul class="breadcrumb">

        <li><a href="dashboard.php?sms=payment&qlk=<?php echo md5(2); ?>">Payments</a> <span class="divider"></span> </li>
        <li class="active" >Hostel fee payments<span class="divider"></span> </li>
    </ul>

<div class="well">
<?php
//check to see if the student have been allocated hostel
$check_school_fee = mysqli_query($conn_1, "SELECT * FROM hostel_allocation WHERE student_id = '$user_id' AND session_id = '$session' ") or die(mysqli_error($conn_1));
        if ($check_school_fee) {

           $sql_sch_fee = mysqli_num_rows($check_school_fee);

            if ($sql_sch_fee > 0) {

?>
    <!-- in the future version check if the current invoice has expired den show but if nt exired dont show -->
    <?php
	if(!has_paid_hostel_fee($user_id, $session ))
	{ ?>

    	<a href="dashboard.php?sms=generate_invoice&for=hf&invoice_to=<?php echo md5(get_user_id());?>&qlk=<?php echo md5(2); ?>"  class="pull-right"><img src="images/add_icon.png" data-toggle="tooltip" data-placement="top"  title="Click here to generate invoice to PAY" />Click here to pay</a> <br/><br/>

    <?php

  }else {
    echo '<a target="_blank" href="create_payment_slip2.php?qlk=<?php echo md5(8);?>&me='.$user_id.'" class="btn btn-info" data-toggle="tooltip" data-placement="top" title="Click here to Print / Download Payment Receipt"><i class="glyphicon glyphicon-print"> </i> Print / Download Receipt</a>';
  }
	?>
	 <div style="height:20px; displat:block;"></div>

<?php
			}else
			{
				echo '<h1>You have not been allocated hostel yet.</h1>';
			}
		}
?>


    <!--First accordion panel container tat accomodates all other payments -->

    <div class="panel panel-success">
        <div class="panel-heading">
            <p class="panel-title">
                <a id="3" data-toggle="collapse" data-parent="#accordion" href="#collapse3"> <span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;PAYMENT HISTORY </a>
                 <span class="label label-primary" style="font-size:15px;float:right;"></span>
            </p>
        </div>
                <div id="collapse3" class="panel-collapse collapse in ">
                    <div class="panel-body">
                        <ul class="list-group">




                                     <!-- accordion for history starts here ###############################################################-->

                                      <div id="accordion" class="panel-group">

                                        <?php $q = "SELECT * FROM sessions  WHERE status = '0' ORDER BY title DESC";
                                                    $r = mysqli_query($conn_1, $q);

                                                    if(mysqli_num_rows($r)>0)
                                                    {
                                                        $a=0; //initialise counter
                                                        while($row = mysqli_fetch_array($r,MYSQLI_ASSOC))
                                                        {
                                        ?>
                                                            <div class="panel panel-info">
                                                                <div class="panel-heading">
                                                                    <p class="panel-title">
                                                                        <a id="<?php echo $a + 1; ?>" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php  echo $a + 1; ?>">
                                                                        <span class="glyphicon glyphicon-plus"></span>
                                                                            <?php echo $row['title']; ?>
                                                                        </a>

                                                                    <span class="label label-primary" style="font-size:15px;float:right;">
                                                                    <?php //echo get_total_votes_per_post($row['id']); //parameter is post id?></span>


                                                                    </p>
                                                                </div>
                                                                        <div id="collapse<?php echo $a + 1; ?>" class="panel-collapse collapse<?php //echo $a + 1; ?>  <?php if($a + 1 =='1'){ echo 'in';} //hide the collapse ?>">
                                                                            <div class="panel-body">
                                                                                <ul class="list-group" >
                                                                                <div class="refresh_me">
                                                                                    <?php

																					    $session = $row['id'];
                                                                                        //collect the post id


                                                                                        echo  show_hostel_fee_payment($user_id, $session);

																					  ?>
                                                                                      </div>
                                                                                    </ul>
                                                                        </div>
                                                            </div>
                                                            <!--First accordion panel container Ends here -->
                                            <?php

                                                        $a++; //increment the loop for the control
                                                        }
                                                    }
                                            ?>

                                                            </div><!-- panel --info-->




                                                            <!-- accordion for history ends here #########################################-->




                    </ul><!-- end of list group --->
                </div><!-- end o panel body -->
    </div>
    <!--First accordion panel container Ends here -->


    </div>
    <!-- payment history -->




</div><!-- /well -->
