<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Prevent direct access to the script.
}

$profile_id   = ! empty( $args['profile_id'] ) ? $args['profile_id'] : '';
$profile_type = ! empty( $args['profile_type'] ) ? $args['profile_type'] : '';

$total_earning  = gigneo_profile_stat( 'total_earning', $profile_id );
$active_orders  = gigneo_profile_stat( 'active_orders_total', $profile_id );
$wallet_balance = gigneo_profile_stat( 'wallet_balance', $profile_id );
?>
<div id="gn-earning-stats" class="gn-dashboard-section gn-section-earning-stats">
	<div class="gn-head">
		<div class="gn-heading-info">
			<h2 class="gn-title"><?php echo esc_html__( 'Earnings', 'gigneo' ); ?></h2>
			<p class="gn-description"><?php echo esc_html__( 'Track your income and billing history.', 'gigneo' ); ?></p>
		</div>
	</div>
	<div class="gn-stat-cards">
		<div class="gn-stat-card gn-total-earnings">
			<div class="gn-head">
				<span class="gn-icon">
					<i class="hi hi-folder-plus" aria-hidden="true"></i>
				</span>
			</div>
			<h3 class="gn-value"><?php echo esc_html( gigneo_price_format( $total_earning['lifetime'], true ) ); ?></h3>
			<h6 class="gn-label"><?php echo esc_html__( 'Total earnings', 'gigneo' ); ?>
				<span class="gn-stat-change gn-<?php echo esc_attr( $total_earning['trend'] ); ?>">
					<?php echo esc_html( number_format( $total_earning['percentage'] ) . '%' ); ?>
				</span>
			</h6>
		</div>
		<div class="gn-stat-card gn-last-thirty-days-speding">
			<div class="gn-head">
				<span class="gn-icon">
					<i class="hi hi-archive-box-arrow-down" aria-hidden="true"></i>
				</span>
			</div>
			<h3 class="gn-value"><?php echo esc_html( gigneo_price_format( $total_earning['last_30'], true ) ); ?></h3>
			<h6 class="gn-label"><?php echo esc_html__( 'Last 30 days', 'gigneo' ); ?>
				<span class="gn-stat-change gn-<?php echo esc_attr( $total_earning['trend'] ); ?>">
					<?php echo esc_html( number_format( $total_earning['percentage'] ) . '%' ); ?>
				</span>
			</h6>
		</div>
		<div class="gn-stat-card gn-wallet-balance">
			<div class="gn-head">
				<span class="gn-icon">
					<i class="hi hi-banknotes" aria-hidden="true"></i>
				</span>
			</div>
			<h3 class="gn-value"><?php echo esc_html( gigneo_price_format( $wallet_balance['last_30'], true ) ); ?></h3>
			<h6 class="gn-label"><?php echo esc_html__( 'Wallet balance', 'gigneo' ); ?>
				<span class="gn-stat-change gn-<?php echo esc_attr( $wallet_balance['trend'] ); ?>">
					<?php echo esc_html( number_format( $wallet_balance['percentage'] ) . '%' ); ?>
				</span>
			</h6>
		</div>
		<div class="gn-stat-card gn-in-escrow">
			<div class="gn-head">
				<span class="gn-icon">
					<i class="hi hi-lock-closed" aria-hidden="true"></i>
				</span>
			</div>
			<h3 class="gn-value"><?php echo esc_html( gigneo_price_format( $active_orders['lifetime'], true ) ); ?></h3>
			<h6 class="gn-label"><?php echo esc_html__( 'In escrow', 'gigneo' ); ?>
				<span class="gn-stat-change gn-<?php echo esc_attr( $active_orders['trend'] ); ?>">
					<?php echo esc_html( number_format( $active_orders['percentage'] ) . '%' ); ?>
				</span>
			</h6>
		</div>
	</div>
</div>