<?php if (!$session->is_logged_in()) {
    redirect_to("index.php");
}
?>
<?php require_once("includes/initialize.php");





$user_data = Userdata::find_by_id($session->user_id);
$biodata = Biodata::find_by_id($user_data->formno, $user_data->email);


if ((substr($user_data->formno,2,2)!=18) and ((substr($user_data->formno,2,2)!=19))){
      
      //echo "All new table: ".substr($user_data->formno,2,2);
      
      Switch(substr($user_data->formno,2,2))
      {
          case '20':$table='form_data';
          break;
          
          case '21': $table='form_data21';
          break;
          
          case '22': $table='form_data22';
      }
      
      
      
       $biodata = Biodata2::find_by_id($table, $user_data->formno, $user_data->email);
       
}








if (isset($biodata->courses)){
    
    $deptC=$biodata->courses;
}else{
    $deptC=$biodata->department;
}









$dp = DEPARTMENTCLASS::department_authenticate($deptC);

$transact_feedbackchk = Transaction::findacceptance($user_data->formno, $user_data->email);
if (!$transact_feedbackchk){
    
    redirect_to ("http://eportal.oscotechesaoke.edu.ng/student_portal/dashboard.php");
 }
//  else {
 
// $transact_feedback2 = Schoolfees::findschoolfees($user_data->formno, $user_data->email);
//  if ($transact_feedback2){
//   redirect_to ("http://eportal.oscotechesaoke.edu.ng/student_portal/dashboard.php");
//   }
 

$alldp = DEPARTMENTCLASS::find_all($dp->faculty);

$current_session = SESSIONCLASS::session_authenticate();

// $formno = $user_data->formno;
// $email = $user_data->email;
$status = $user_data->status;
// $access = Userdata::Allow_access($statu,$formno,$email);
if ($status == 'closed')
{ redirect_to ("http://eportal.oscotechesaoke.edu.ng/student_portal/dashboard.php"); }

//$total_sc_fees = 0;

foreach ($alldp as $aldp) {
    $faculty = $aldp->faculty;
}
$pay_cat = '';
//echo "<br>Faculty: ".$faculty;
if ($faculty == 'Engineering' or $faculty=='Pure and applied Sciences' or $faculty == 'Applied Sciences' or $faculty == 'Environmental Studies' or $faculty=='Information Communication and Technology') {
    $pay_cat = 'science';
} elseif ($faculty == 'Business and Management Sciences') {
    $pay_cat = 'nonscience';
}

if (isset($biodata->programme)){
 $level = $biodata->programme;   
}else {
    $level = $biodata->level;
}


 if ($level=='ND I'){
    $level = $level.'I';
}else if ($level=='HND I'){
    $level = $level.'I';
}

 $adm_type = (substr($user_data->formno, 0, 2));
if (($adm_type == 'PU') or ($adm_type == 'FT')) {
            $adm_type = 'regular';

        } elseif ($adm_type == 'DP') {

            $adm_type = 'dailypt';
        }


//$pay_settings = Pay_settings::authenticate(3,$level,$pay_cat);

//$biodata = Biodata::find_by_id($session->user_id);

//$total = Pay_settings::find_sch_fees(3, $level, $pay_cat, $adm_type);

//$transact = Schoolfees::t_processing($id);

//echo "Current Session: ".$current_session->session;
$transaction = Schoolfees::authenticate($current_session->session, $user_data->formno, $user_data->email);

//$session->message("Testing message ");

//	$message =$transaction->responsecode;

//echo "dsdjskj "."{$transaction->responsecode}";

//echo $session->message;
?>

<div class="art-content-layout">
    <div class="art-content-layout-row">

        <div class="art-layout-cell layout-item-0" style="width: 100%">

            <marquee behavior="alternate" scrolldelay="200" onmouseover="this.setAttribute('scrollamount',0,0);"
                     onmouseout="this.setAttribute('scrollamount',6,0);">
                <div style="color:#F00; font-style:italic; font-weight:bolder;">NOTE: <span
                            style="color:#F00; font-style:italic;">Upon successful payment of the school fees, click Registration Module to register for your courses</span>
                </div>
            </marquee>


        </div>
    </div>
</div>
<div class="art-content-layout">
    <div class="art-content-layout-row">

        <div class="art-layout-cell layout-item-0" style="width: 100%">


            <div style="text-transform:uppercase; color:#099; font-weight:bolder; border-bottom:inset #000 thin;">school fees payment
            </div>
            <?php if ($message != 'Approved Successful') {
                echo output_message($message);
            } elseif ($message == 'Approved Successful') {
              //  echo "<script>window.open('acceptance_receipt.php')</script>";
                echo "<span style=\"color:#060; font-weight:bolder \">{$message}</span>";
                $_SESSION['success'] = $message;
            } else {
                echo output_message($message);
            }

            ?>
        </div>
    </div>
</div>


<div class="art-content-layout">
    <div class="art-content-layout-row">
        <div class="art-layout-cell layout-item-0" style="width: 30%; background-color:#FFF; margin:0; padding:0;">
            <div>
                <div style="border-bottom:inset thin #0FC; width:100%; margin:0;background-color:#096 "><a
                            href="javascript:void(0)"
                            style="color:#FFF; font-size:17px; text-decoration:none; display:block ">Make
                        payment</a></div>

                <div style="border-bottom:inset thin #0FC;background-color:#096 "><a href="javascript:void(0)"
                                                                                     style="color:#FFF; font-size:17px; text-decoration:none; display:block">Re-generate
                        pin</a></div>
                <div style="border-bottom:inset thin #0FC;background-color:#096 "><a href="javascript:void(0)"
                                                                                     style="color:#FFF; font-size:17px; text-decoration:none; display:block">Create
                        ticket</a></div>
                        </div>
                        
                       <!--<div><img src="images/image001.png" width="50px" height="20px"-->
                       <!--                     </div> -->
             <img src="images/image001.png" width="231" height="70" style="margin-top:0px; padding:0; margin-left:0px; margin-right:0px; margin-bottom:0; background-color:#FFF; " />   
    </div>


        <div class="art-layout-cell layout-item-0" style="width: 70%">

            <div style="font-size:16px; margin-right:20px "><label style="font-size:16px">Your details are:</label>
            </div>
            <div style="font-size:16px; margin-right:20px "><label style="font-size:16px; margin-right:23px ">Form
                    Number:</label><?php echo $biodata->formno; ?></div>

            <div style="font-size:16px; margin-right:20px "><label
                        style="font-size:16px; margin-right:54px ">Fullname:</label><?php echo $biodata->surname . ", " . $biodata->othernames; ?>
            </div>
            <div style="font-size:16px; margin-right:20px "><label style="font-size:16px; margin-right:37px ">Department:</label><?php echo $deptC; ?>
            </div>
            <div style="font-size:16px; margin-right:20px "><label
                        style="font-size:16px; margin-right:83px ">Level:</label><?php echo $level; ?></div>

            <table id="schltable" border="2" align="center" class="" width="100%">
                <tr>
                    <th>S/N</th>
                    <th>Fees Description</th>
                    <th>Amount</th>

                </tr>

                <?php

                $count = 0;
                $total_sc_fees = 0;
                
                //  if (substr($user_data->formno,2,2)>=22){
                //   $status=0;
                //     $total = Pay_settings::find_sch_fees(3, $level, $pay_cat, $adm_type,$status);
                // }else{
                 //  echo  $level.": ". $pay_cat.": ". $adm_type;
                   $status=0;
                    $total = Pay_settings::find_sch_fees(3, $level, $pay_cat, $adm_type, $status);
                // }
                 
               
				//$total = Pay_settings::find_sch_fees(3, $level, $pay_cat, $adm_type);
                //$total = Pay_settings::find_all(3, $level, $pay_cat);

                foreach ($total as $samount) {
                    $total_sc_fees += $samount->amount;


                    echo '<tr>'
                        . '<td>' . ++$count . '</td>'
                        . '<td>' . ucfirst($samount->fees_description) . '</td>'
                        . '<td>' . ucfirst($samount->amount) . '</td>'
                        . '</tr>';
                } ?>

            </table>


            <hr/>


            
            <div style=" font-size:16px; font-weight:bolder;"><label style="font-size:16px">Total payable school
                    fees: </label>
                <?php echo $total_sc_fees . ".00";
                /*+$pay_settings->charge_interswitch + $pay_settings->charge_omoluabi.*/
                ?></div>
            <hr/>

           <?php
            //if ($_SESSION['success']=='Approved Successful'){
                $_SESSION['m']=2;

            //}else{
            if ((!$transaction) or $transaction->responsecode != '00') :
                echo '<a href="schoolfees_tranzact.php" id="accept" 
style="background-color:#030; color:#FFF; font-weight:bolder; border-radius:5px;padding:5px; margin-top:5; 
text-decoration:none; font-size:17px; font-stretch:extra-expanded">Proceed</a>           

            <a href="dashboard.php" id="back"
               style="background-color:#030; color:#FFF; font-weight:bolder; border-radius:5px;padding:5px; margin-top:5; margin-left:20px ; text-decoration:none; font-size:17px; font-stretch:extra-expanded">
                Back</a>';

            else :
                echo '  <a href="schoolfees_receipt.php" target="_self"
               style="background-color:#030; color:#FFF; font-weight:bolder; border-radius:5px;padding:5px; margin-top:5; margin-left:20px ; text-decoration:none; font-size:17px;
                font-stretch:extra-expanded">
                Print Receipt</a>';
            endif;
            ?>
            </form>

            <?php if ((!$transaction) or $transaction->responsecode != '00') : ?>
                <div>
                    <div class="row">
                        <span class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
                            <img src="./images/image001.png" class="img-responsive bankImg" alt="">
                        </span>
                        <span class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
                            <img src="./images/mc.jpg" class="img-responsive bankImg bankFix" alt="">

                        </span>
                        <span class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
                            <img src="./images/visa.png" class="img-responsive bankImg" alt="">

                        </span>
                        <span class="col-md-3 col-lg-3 col-sm-3 col-xs-3">
                            <img src="./images/verve.jpg" class="img-responsive bankImg" alt="">

                        </span>
                    </div>
                </div>
            <?php endif; ?>

        </div>
    </div>
</div>
</div>


</article></div>

<style>
    #accept:hover {
        text-decoration: none;
        font-style: italic;
    }
</style>


<script type="text/javascript">

    var mes = <?php echo json_encode($message);?>
        $(document).ready(function () {
            alert(mes)
            if (mes == "Approved Successful") {
                $('#accept').attr('disabled', 'disabled');
            };
        })
        </script>
        
