<?php
/************************************************************************/
/*     PROGRAMMER     :  SMA                                            */
/*     SCRIPT NAME    :  linkpayment.php             			        */
/*     CREATED ON     :  15/JULY/2006                                   */
/*     MODERNIZED     :  20/AUG/2025                                    */
/************************************************************************/

require_once 'adminuser.php'; // Ensure your class is loaded
// Assume session_start() is already called globally

$userobj = new adminuser();
$adminUserId = $_SESSION['ADMINUSERID'] ?? null;

if (!$adminUserId) {
    include 'permission_denied.php';
    exit;
}

if ($userobj->GetAdminUserLink('View Affiliate Requests', $adminUserId, 4)) {
    header("Location: index.php?Act=request");
    exit;
}

if ($userobj->GetAdminUserLink('View Merchant Requests', $adminUserId, 4)) {
    header("Location: index.php?Act=mer_requests");
    exit;
}

if ($userobj->GetAdminUserLink('View Reverse Sales', $adminUserId, 4)) {
    header("Location: index.php?Act=reverse_payments");
    exit;
}

if ($userobj->GetAdminUserLink('View Reverse Recurring Sales', $adminUserId, 4)) {
    header("Location: index.php?Act=reverse_recur_payments");
    exit;
}

if ($userobj->GetAdminUserLink('View Invoices', $adminUserId, 4)) {
    header("Location: index.php?Act=invoice");
    exit;
}

// If no permissions matched
include 'permission_denied.php';
exit;
?>
