<?php


//get current session
 $session = get_current_session($id = 1);
 /*echo $user_id;*/
//when screening fees no paid and applicant not admitted
if(!has_paid_acceptance_fee($user_id, $session)){
     header('Location: dashboard.php');

}

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

    <ul class="breadcrumb">

        <li><a href="dashboard.php?act=payments&qlk=<?php echo md5(8); ?>">Payments</a> <span class="divider"></span> </li>
        <li class="active" >School fee payments<span class="divider"></span> </li>
    </ul>

<div class="well">

    <!-- in the future version check if the current invoice has expired den show but if nt exired dont show -->
    <?php

       $ap_no = get_user_application_number($user_id);
       $stud_id = get_student_id_by_app_no_nce($ap_no);

       //for DUAP programme we have to sue jamb no becasue we didnt use application

       $jamb_no = get_user_jamb_no($user_id);
       $stud_id = get_student_id_by_jamb_no_nce($jamb_no);



if($stud_id != '')

{
   // echo $user_id ;
    if(has_paid_school_fee($stud_id, $session )){ // show receipt and add print admission letter on the main menu/ show receipt and add print admission letter on the main menu


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



            <a target="_blank" href="create_sf_payment_slip.php?qlk=<?php echo md5(8);?>&me=<?php echo $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>


    <?php
    }else{

        ?>

             <div class="btn-group">
              <button type="button"   class="btn btn-success dropdown-toggle pull-right" data-toggle="dropdown">
               <i class="glyphicon glyphicon-plus-sign"></i> Generate New Invoice <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">

               <!--  <li><a href="dashboard.php?act=generate_invoice&for=sf&pm=1&invoice_to=<?php echo md5(get_user_id());?>&qlk=<?php// echo md5(8); ?>" >INSTALMENT PAYMENT</a></li>
                <li class="divider"></li> -->
                <li ><a href="dashboard.php?act=generate_invoice&for=sf&&pm=2&invoice_to=<?php echo md5(get_user_id());?>&qlk=<?php echo md5(8); ?>">FULL PAYMENT</a></li>
              </ul>
            </div>


    <?php
    }

}
else
{

    ?>


     <div class="btn-group">
              <button type="button"   class="btn btn-success dropdown-toggle pull-right" data-toggle="dropdown">
               <i class="glyphicon glyphicon-plus-sign"></i> Generate New Invoice <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">

               <!--  <li><a href="dashboard.php?act=generate_invoice&for=sf&pm=1&invoice_to=<?php echo md5(get_user_id());?>&qlk=<?php// echo md5(8); ?>" >INSTALMENT PAYMENT</a></li>
                <li class="divider"></li> -->
                <li ><a href="dashboard.php?act=generate_invoice&for=sf&&pm=2&invoice_to=<?php echo md5(get_user_id());?>&qlk=<?php echo md5(8); ?>">FULL PAYMENT</a></li>
              </ul>
            </div>
<?php

}




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




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

    <div class="panel panel-warning">
        <div class="panel-heading">
            <p class="panel-title">
                <a id="Me" data-toggle="collapse" data-parent="#accordion" href="#collapseMe"> <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="collapseMe" class="panel-collapse collapse in ">
                    <div class="panel-body">
                        <ul class="list-group">


                            		 <div class="alert alert-info in" >
                                         <button class="close" data-dismiss="alert" type="button">
                                            X

                                         </button>
                                            <i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;Please click on the green-plus-sign above to generate new invoice for SCHOOL FEE payment, but if you have generated an invoice before, check your invoice history to print most recent.
                                    </div>




                                      <div class="col-lg-12 col-xs-6">

                                        <h3 class="help-block">My Invoices
                                          <a class="btn btn-danger btn-sm" href="#" data-toggle="modal" data-target="#myModalSchTLOG"> View Transaction Status</a>
                                        </h3>
                                        <p class="help-block">Your invoice history with us </p>


                                        <?php

                                            echo view_invoices($user_id, $invoice_type = 1, $invoice_for = 2, $session); ?>

                                    </div><!-- /.col lg 12 -->



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

                                     <?php /*?> <div id="accordion" class="panel-group">

                                        <?php $q = "SELECT * FROM sessions  WHERE status = '0' ORDER BY title DESC";
                                                    $r = mysqli_query($dbc, $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_school_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-->

                                     <?php */?>


                                                            <!-- 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 -->
