<?php require_once("includes/initialize.php");
//$par = array();
global $database;
ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$id = $session->user_id;
$user_data = Userdata::find_by_id($session->user_id);


echo $user_data->formno.' '.$user_data->email;
$amount='20000';

switch(substr($user_data->formno,2,2))
{
    case '21':$table='form_data21';
    break;
    case '22':$table='form_data22';
    break;
    case '23':$table='form_data23';
    break;
}

$biodata = Biodata::find_by_id($user_data->formno, $user_data->email,$table); 
$feeCode=1; 
$plevel='';
//echo 'Test found: '.substr($user_data->formno,2,2);
//echo $strecord = Userdata::find_by_remita($user_data->formno);
//echo $biodata->level.' I';
//$plevel= 20000;// $biodata->level.' I';

//echo $feeCode.'   '.$plevel;
//$acceptanceFee=Biodata::getAcceptanceAmount($feeCode,$plevel);

//echo 'Amount: '.

$acceptanceFee=20000;

echo $biodata->department;

if (isset($biodata->department)){
 
 $stu_fac=Biodata::getFac($biodata->department);
  echo 'Faculty: '.$stu_fac->faculty; 
}

if (isset($biodata->formno)){
$formno=$biodata->formno;
$surname = $biodata->surname;
$othernames = $biodata->othernames;
$faculty =  $stu_fac->faculty;
$department =  $biodata->department;
$level = $biodata->level.' I';
$phone = $biodata->phone;
$amount = $acceptanceFee;
$session= $biodata->session;
$email = $biodata->email;
}

//$current_session = SESSIONCLASS::session_authenticate();
//s($formno,$surname,$othernames,$department,$level,$phone,$amount,$session,$email)
$paymentDetails=Biodata::savePaymentDetails($formno, $surname,$othernames,$faculty,$department,$level,$phone,$amount,$session,$email);

if (isset($paymentDetails))
{
    $_SESSION['paymentID']= $paymentDetails;
    header("location: dashboard.php?type=remitadetails");
}

//if ($paymentDetails){
    echo 'Save: '.$paymentDetails;
    //echo 'Dti: '.$paymentDetails->id;
//}






// $a = (substr(rand(1, 10000000000), 0, 10));
// $txt_ref = $a . (substr($biodata->surname, 0, 2));

//@todo:fix //inserts into the acceptance_tranz table from here
//$transact = Transaction::t_processing($id, $biodata->session, $txt_ref);
//$transaction = Transaction::find_by_txnref($txt_ref);


// $fno = $transaction->formno;
// $txn_ref = $transaction->txt_ref;
// $level = $transaction->level;
// $full_name = $transaction->surname . ' ' . $transaction->othernames;
// $surname = $transaction->surname;
// $othername = $transaction->othernames;
// $amount = $transaction->amount;
// $courses = $transaction->department;
// $email = $transaction->email;
// $phone = $transaction->phone;

// $level0 = $transaction->programme;
// $session = $transaction->session;
// $transfee = $transaction->txt_fees;
// $overhead = $transaction->overhead;
// $_SESSION['txn_ref'] = $txn_ref;
// $_SESSION['wayout'] = "Acceptance Fee";
// $charges = $transfee + $overhead;
// $amount_new = $amount - $charges;


// $fname = $transaction->surname . ' ' . $transaction->othernames;

//@todo: fix //into webpaylog
// $sqlw = $database->query("INSERT INTO webpaylog (txnref,datetime,debittedamount,responsedesc,responsecode,custname,custid) 
// 						VALUES('$txn_ref',NOW(),'$amount','null','null','$fname','$fno')") or die(mysql_error());


//header("location: dashboard.php?type=invoicedetails");

?>


	