<?php 
//echo "<script type='text/javascript'>alert('Fail, Please Try Again');</script>";

date_default_timezone_set("Asia/Kuala_Lumpur");
$created_date = date('Y-m-d H:i:s');
$created_date = date('d-m-Y h:i:s a ', strtotime($record['created_date']));

$sql_user = "SELECT * 
FROM user 
WHERE ref_code='$ref_code'
And status='1'";
$result_user = $mysqli->query($sql_user);
if ($result_user ->num_rows > 0)
{
	$row_user = $result_user ->fetch_assoc();
	$type_of_user = $row_user['type_of_user'];
    $name = $row_user['name'];
    $last_name = $row_user['last_name'];
    $email = $row_user['email'];
    $phone_number = $row_user['phone_number'];
}  

$sql_product = "SELECT *
				FROM package_setting
				Where package_ref_code  = '$order_item_sku'
				And status='1'";
$result_product = $mysqli-> query($sql_product);
if ($result_product -> num_rows > 0)
{
	$row_product = $result_product ->fetch_assoc();
	$product_id = $row_product['id'];
	$package_price = $row_product['package_price'];
}

$sql_order_item = "SELECT *
					FROM package_payment
					WHERE order_id  = '$order_id'
					AND trans_code  = '$trans_code'
					AND ref_code  = '$ref_code'
					AND status='1'
					LIMIT 1";
$result_order_item = $mysqli-> query($sql_order_item);
if ($result_order_item -> num_rows > 0)
{
	$row_order_item = $result_order_item ->fetch_assoc();
	$full_amount  = $row_order_item['full_amount'];
}

$sql_package_purchase = "SELECT *
                        FROM woocommerce_order_info
                        Where new_ref_code = '$ref_code'
                        And status = '1'
                        order by id Desc";
$result_package_purchase = $mysqli-> query($sql_package_purchase);
if ($result_package_purchase -> num_rows > 0)
{
	$row_package_purchase = $result_package_purchase ->fetch_assoc();
	$order_id  = $row_package_purchase['order_id'];
    $trans_code  = $row_package_purchase['trans_code'];
    $new_ref_code  = $row_package_purchase['new_ref_code'];
    $order_items  = $row_package_purchase['order_items'];
    $order_full_total  = $row_package_purchase['order_full_total'];
    $order_total  = $row_package_purchase['order_total'];
    $paid_date = date('d-m-Y H:i:s', strtotime($row_package_purchase['paid_date']));
    $created_date = date('d-m-Y H:i:s', strtotime($row_package_purchase['created_date']));
}


$sql_currency = "SELECT *
FROM currency_rate_setting 
WHERE status='1'";
$result_currency = $mysqli->query($sql_currency);
$row_currency = $result_currency->fetch_assoc();
$deposit_rm = $row_currency['deposit_rm'];	

?>