<?php

session_start();
require '../lib/dbclass.php';




$clubid  = $_POST['clubid'] ? $_POST['clubid'] : 0;
$Amount  = $_POST['Amount'];
$orderid = $_POST['orderid'];

unset($_POST['Amount']);
unset($_POST['clubid']);
unset($_POST['orderid']);

if (!$_POST['Assembly']) {
    $dataassem         = findQuery('select * from tbl_assembly where district=0');
    $_POST['Assembly'] = $dataassem[0]['id'];
}

if (!$_POST['Panchayat']) {
    $datapan            = findQuery('select * from tbl_panchayat where assembly_id=0');
    $_POST['Panchayat'] = $datapan[0]['id'];
}

if (!$_POST['Ward']) {
    $datawrd       = findQuery('select * from tbl_ward where panchayat_id=0');
    $_POST['Ward'] = $datawrd[0]['id'];
}

if ($orderid != '') {
    $_POST_HDR['is_Razor_payment_gateway'] = 2;
}


$custid = saveArray('tbl_customer', $_POST, 0); //customer save

$_POST_HDR['clubid']     = 0;
$_POST_HDR['donation']   = 1;
$_POST_HDR['customerid'] = $custid;
$_POST_HDR['orderid']    = $orderid;
$_POST_HDR['Amount']     = $Amount;
$_POST_HDR['Received']   = $Amount;
$_POST_HDR['uniquedid']  = '0ebdbfdcb3087511bef20bb0f8751f2808e27d12a7f595c3ae8b28b022203aca';


$hdrid = saveArray('tbl_transaction', $_POST_HDR, 0); //transaction save




$message = 'Added successfully!';

$encodedMessage = urlencode($message);

$url = "challengereport.php?message={$encodedMessage}";

// Redirect to the new URL
echo "<script>window.location.href='{$url}';</script>";
