<?php
// Load required resources
include_once '../includes/constants.php';
include_once '../includes/functions.php';
include_once '../includes/session.php';
include_once '../includes/allstripslashes.php';

// Create partners object and connect
$partners = new partners();
$partners->connection($host, $user, $pass, $db);

// Retrieve session-based sorting tables
$sortingtable = $_SESSION['SORTINGTABLE'] ?? '';
$mer_sortingtable = $_SESSION['MER_SORTINGTABLE'] ?? '';

// Drop affiliate heap table if set
if (!empty($sortingtable)) {
    $dropQuery = "DROP TABLE IF EXISTS admin_affil_heap";
    $mysqli->query($dropQuery);
    $_SESSION['SORTINGTABLE'] = "";
}

// Drop merchant heap table if set
if (!empty($mer_sortingtable)) {
    $dropQuery = "DROP TABLE IF EXISTS admin_mer_heap";
    $mysqli->query($dropQuery);
    $_SESSION['MER_SORTINGTABLE'] = "";
}
?>
