<?php
		require_once 'singles.php';

$emptyArray=array();
		$send_type = 'send money';
		$send_type2 = 'received money';
	$q="select * from trans where email = '$mail' and type='$send_type' OR email = '$mail' and type='$send_type2' order by id desc";
	$r= mysqli_query($conn,$q);
	while($qr= mysqli_fetch_assoc($r)){
		$status=$qr['status'];
		$dt = strtotime($qr['created_at']);
	
	$icon_right = '<div class="icon">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" icon-name="arrow-right
            " class="lucide lucide-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>
    </div>';
	
	$icon_ = ($send_type == 'send money') ? $icon_right : $icon_left;
	
		$desc = '<div class="table-description">
		'.$icon_.'
		<div class="description">
			<strong> '.ucwords($qr['description']).' </strong>        <div class="date"> '.date('M d Y h:i',$dt).'</div>
		</div>
	</div>';
		

				$amount = ($qr['type'] == $send_type2) ? '<strong class="green-color">+'.$qr['amount'].' USD</strong>' :'<strong class="red-color">-'.$qr['amount'].' USD</strong>';
		
		if(strtolower($status) == 'pending'){
			$status = '<div class="site-badge warnning">Pending</div>';
		}elseif(strtolower($status) == 'success'){
			$status = '<div class="site-badge success">Success</div>';
		}elseif(strtolower($status) == 'canceled' || strtolower($status) == 'cancel' || strtolower($status) == 'cancelled' ){

			$status = '<div class="site-badge primary-bg">Canceled</div>';

		}else{$status = '<div class="site-badge warnning">Pending</div>';}

		$arr = array('description'=>$desc, 'tnx'=>$qr['trans_id'], 'amount'=> $amount, 'status'=> $status, 'method'=> strtoupper($qr['method']), 'charge'=>$qr['fee']);
		array_push($emptyArray, $arr);
	}

	$p = array('data'=>$emptyArray);
	 $plans_obj2 =  (json_encode($p));
	 
	 print($plans_obj2);
		

?>