<?php
 include '../config/index.php';
 include '../module/index.php';
 
$data = new Database;

$con = $data->connect();

$user = new User($con);

$post = filter_var_array($_POST,FILTER_SANITIZE_FULL_SPECIAL_CHARS);

$otp = $post['code'];

$session_code = $_SESSION['otp'];


if($otp != $session_code){
   $_SESSION['t_error_c'] = 'Invalid Swift MT103 Code';
   echo $data->redirect('../account/../index?mt=mt');
}else{

   $user_name = $_SESSION['first_name'];
   $type = 'Debit';
   $d = 'DT';
   $user_id = $_SESSION['id'];
   $amount = $_SESSION['inter_amount'];

   $reference = uniqid();
   $date      = new DateTime();
   $dates     = $date->format('d M y, h:i a'); // 21 Dec 22, 08:39 pm
   $status    = 'complete';

   echo $user->fundTransfer($amount);
   
   echo $user->createTransaction($amount,$user_id,$reference,'nill',$dates,$status,$type,$user_name.'/'.$d.'_'.$reference.'>'.$amount);

   echo $user->InterTransfer($_SESSION['int']['name'],$_SESSION['int']['sort'],$_SESSION['int']['accountnumber'],$_SESSION['inter_amount'],$_SESSION['int']['bank'],$_SESSION['int']['country'],$_SESSION['int']['city'],$_SESSION['description']);

   $_SESSION['t_error_c']  = 'Transaction has been successful, it may take 3 to 10 working day for it to reflect on the recipient account';

   echo $data->redirect('../account/../index?home=home');

}







?>