
<?php $security_id = get_security_id($user_id);//collect security id ?>
<ul class="breadcrumb">
     <li><a href="gateway.php?act=view_students_payments_b">Students Confirmation Menu</a> <span class="divider"></span></li>
     <li><a href="gateway.php?act=view_search_students_b">Search Student Invoice ID </a>  <span class="divider"></span></li>
     <li class="active"> Confirmed Payments</li>
 </ul>
<div class="well">

     <ul class="tabs">
       <li><a href="#view1">Student Info</a></li>
     </ul>
     <div class="tabcontents">
       <div id="view1"  style="background-image:images/background.png;">

         <!-- this is the search button -->

          <div class="row">

             </div>

        <div class="row alert alert-success">

               <div style="float:left; width:90%">

                       <img src="images/coe.png"   class="pull-left"/>

                       <p class="text-center"> <span style="font-size:20px;font-weight:bold;"><br/>Students' Payment Confirmation Slip </span> </p> <br/>
                       <p class="text-center">
                       <span align="center" style="font-size:20px;font-weight:bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NIGER STATE COLLEGE OF EDUCATION MINNA  </span>  <br/>
                       <span align="center"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(HOSTEL MANAGEMENT PORTAL)  </span>  <br/>
                       <span align="center" style="font-size:20px;font-weight:bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STUDENT PORTAL  </span>
                       </p><br/>

                       <!--<p class="info text-center">Please visit the portal to continue application</p>-->

             </div>


             <div style="float:left; width:10%">
                <img src="images/payments.png" />


               </div>


           </div><!-- /alert info -->

             <?php

       //colllect the id to generate the password for candidate


       //check the action passed
       if(($_POST['act']== 'confirm_students_payments_b'))
       {
         //************************ special case *********************/

         $id_array = $_POST['invoice']; // return array
         $id_count = count($_POST['invoice']); // count array

         for($i=0; $i < $id_count; $i++) {

           //collect the id through aray
           $id = $id_array[$i];




           //get invoice to
          $invoice_to  = get_invoice_invoice_to($id);

          //get invoice type
          $invoice_type = get_invoice_type($id);

          //get invoice title
          $invoice_title = get_invoice_title($id);


          //get invoice desc
          $invoice_desc = get_invoice_desc($id);

          //get invoice amount
          $invoice_amount = get_invoice_amount($id);

          //get invoice amount
          $payment_mode = get_invoice_payment_mode($id);


          //get current session
          //$current_session = get_current_session(1);
		  $current_session = 6;

          //get current semester
          $current_semester = get_current_semester(1);





            if($invoice_type == '5') //end if invoice type is student
           {
             //insert the candidate as a student

             //get student details to make payment
             //student programme type
             $student_programme_type = get_student_programme_type_id($invoice_to);//get student pt

             //student department
             $student_department = get_student_department_id($invoice_to);



             //student department
             $student_programme = get_student_programme_id($invoice_to);

             //student department
             $actual_programme_id = get_programme_actual_programme_id($invoice_to);


             //$student_level = '100'; //aplicant level


            if(!student_id_exist_payments($invoice_to, $current_session))
            {

               $qqq1 = "INSERT INTO `hostel_fee_payments`(`id`, `programme_type_id`, `department_id`, `programme_id`,
                   `actual_programme_id`, `session_id`, `semester_id`, `student_id`, `payment_status`,`payment_mode`, `invoice_id`,
                    `title`, `description`, `amount`, `date_added`, `added_by`)
                    VALUES (NULL,'$student_programme_type','$student_department','$student_programme',
                   '$actual_programme_id', '$current_session','$current_semester','$invoice_to','1','$payment_mode',
                   '$id','$invoice_title','$invoice_desc','$invoice_amount',NOW(),'$security_id')";

               $rrr1 = mysqli_query($conn_1,$qqq1);

               if($rrr1)//mysqli_affected_rows($dbc)
               {
                 //if done finally collect all info for receipt


                 //update invoice status to paid
                  mysqli_query($conn_1, "UPDATE hostel_invoices SET payment_status = '1' WHERE invoice_id = '$id'");



                   $output = '';

                   $output .= '<ul class="list-group">';

                   $output .= '<li class="list-group-item help-block">Date / Time: '.date('Y-m-d-His').'  <span class="pull-right">ID:<strong>'.$id.' </strong> </span></li>  <hr/>';


                   $output .= '<li class="list-group-item help-block" >Name: <b>'.get_student_fullname($invoice_to).'</b></li> <hr/>';

                   $output .= '<li class="list-group-item help-block" >Session:<b>'.get_session_title($current_session).'</b> <span class="pull-right">Semester:<b>'.get_semester_title($current_semester).'</b><strong> </strong> </span></li>';


                   $output .= '<li class="list-group-item help-block" >Matric No.:<b>'.get_student_matric_number($invoice_to).'</b> <span class="pull-right">Course :<b>'.get_programme_title(get_student_programme_id($invoice_to)).'</b> </span></li> <hr/>';

                   $output .= '<li class="list-group-item help-block" >The Sum of N'.number_format($invoice_amount ,2).'K </li>';

                   $output .= '<li class="list-group-item help-block" >Description of Items:


                           <br/>
                           <span>'.$invoice_title.'
                             </span>
                           <br/>

                             <span>'.$invoice_desc.'
                             </span>
                         </li>';

                    $output .= '<li class="list-group-item help-block" style="min-height:60px;" >
                         <span class="pull-right text-success" style="font-size:35px; font-weight:bold;">Total Paid: N'.number_format($invoice_amount ,2).'K </span>
                         </li>';


                    $output .= '<li class="list-group-item help-block" style="min-height:20px;color:#foo;" >
                          Please visit "accommodation.coeminna-edu.ng" with login  details matric number and default password  "0000" to continue your registration process
                         </li>';




                   $output .= '<li class="list-group-item"> <a href="javascript:doit()"><img src="images/print_big.png" border=0 align="middle" class="pull-right" title="Print" data-toggle="tooltip"> </a> </li>';





                   $output .= '</ul>';

                   echo $output;


               }
               else
               {
                  //else tell the admin to reprint
               }

            }//end of if student doesnt exist
            else
            {//if student exist

                     $output = '';

                   $output .= '<ul class="list-group">';

                   $output .= '<li class="list-group-item help-block">Date / Time: '.date('Y-m-d-His').'  <span class="pull-right">ID:<strong>'.$id.' </strong> </span></li>  <hr/>';


                   $output .= '<li class="list-group-item help-block" >Name: <b>'.get_student_fullname($invoice_to).'</b></li> <hr/>';

                   $output .= '<li class="list-group-item help-block" >Session:<b>'.get_session_title($current_session).'</b> <span class="pull-right">Semester:<b>'.get_semester_title($current_semester).'</b><strong> </strong> </span></li>';


                   $output .= '<li class="list-group-item help-block" >Matric No.:<b>'.get_student_matric_number($invoice_to).'</b> <span class="pull-right">Course :<b>'.get_programme_title(get_student_programme_id($invoice_to)).'</b> </span></li> <hr/>';

                   $output .= '<li class="list-group-item help-block" >The Sum of N'.number_format($invoice_amount ,2).'K </li>';

                   $output .= '<li class="list-group-item help-block" >Description of Items:


                           <br/>
                           <span>'.$invoice_title.'
                             </span>
                           <br/>

                             <span>'.$invoice_desc.'
                             </span>
                         </li>';

                    $output .= '<li class="list-group-item help-block" style="min-height:60px;" >
                         <span class="pull-right text-success" style="font-size:35px; font-weight:bold;">Total Paid: N'.number_format($invoice_amount ,2).'K </span>
                         </li>';


                    //$output .= '<li class="list-group-item help-block" style="min-height:20px;color:#foo;" >
                       //   Please visit "www.students.ndp.ibbuconsult.com.ng" with login  details matric number and default password  "0000" to continue your registration process
                       //   </li>';




                   $output .= '<li class="list-group-item"> <a href="javascript:doit()"><img src="images/print_big.png" border=0 align="middle" class="pull-right" title="Print" data-toggle="tooltip"> </a> </li>';





                   $output .= '</ul>';

                   echo $output;

            }//end of if student already exist










           }//end of if invoice type is student







       ?>





               <?php







         }//end of for loop for collecting the id


        }//end of if act is confirm payment



      //display the information





       ?>


             <!--<img src="images/background.png" border=0 align="middle"  title="Print"> -->


       </div>

     </div>
</div>

</form>
