<?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'] : '';
$platform_type = ! empty( $args['platform_type'] ) ? $args['platform_type'] : '';
$credit_system = ! empty( $args['credit_system'] ) ? $args['credit_system'] : '';

$credit_rate = gigneo_option( '_gigneo_ts_credit_rate', '1' );

$privacy_page_id = gigneo_option( '_gigneo_ts_template_privacy_policy' );
$terms_page_id   = gigneo_option( '_gigneo_ts_template_terms_and_condition' );
$terms_url       = $terms_page_id ? esc_url( get_permalink( $terms_page_id ) ) : '#';
$privacy_url     = $privacy_page_id ? esc_url( get_permalink( $privacy_page_id ) ) : '#';
$terms_title     = $terms_page_id ? esc_html( get_the_title( $terms_page_id ) ) : esc_html__( 'Terms and Condition', 'gigneo' );
$privacy_title   = $privacy_page_id ? esc_html( get_the_title( $privacy_page_id ) ) : esc_html__( 'Privacy Policy', 'gigneo' );
?>
<div id="gn-credit-history" class="gn-dashboard-section gn-section-credit-history">
	<div class="gn-head">
		<h3 class="gn-title"><?php echo esc_html__( 'Buy credits', 'gigneo' ); ?></h3>
	</div>
	<form id="gn-purchase-credits-form" class="gn-theme-form gn-purchase-credits-form">
		<div class="gn-body">
			<fieldset class="gn-form-fields">
				<div class="gn-form-field">
					<label for="gn-total-purchase-credits" class="gn-required-field-label"><?php echo esc_html__( 'Credits', 'gigneo' ); ?></label>
					<input id="gn-total-purchase-credits" min="1" step="1" class="gn-required-field" type="number" name="credits" autocomplete="off" placeholder="<?php echo esc_attr__( 'Enter credits', 'gigneo' ); ?>">
				</div>
			</fieldset>
			<div class="gn-form-summary">
				<h6 class="gn-title"><?php echo esc_html__( 'Summary', 'gigneo' ); ?></h6>
				<div class="gn-summary-info">
					<div class="gn-info gn-per-credit-rate">
						<span class="gn-label"><?php echo esc_html__( 'Credit rate', 'gigneo' ); ?></span>
						<span class="gn-value"><?php echo esc_html( gigneo_price_format( $credit_rate, true ) ); ?></span>
					</div>
					<div class="gn-info gn-total-amount">
						<span class="gn-label"><?php echo esc_html__( 'Payable amount', 'gigneo' ); ?></span>
						<span id="gn-total-credit-amount" class="gn-value"><?php echo esc_html( gigneo_price_format( 0, true ) ); ?></span>
					</div>
				</div>
			</div>
			<fieldset class="gn-form-fields">
				<div class="gn-form-field">
					<div class="gn-form-field-checkbox">
						<input id="gn-term-and-privacy" type="checkbox" class="gn-required-field" value="yes" name="term_and_privacy"/>
						<label for="gn-term-and-privacy">
							<?php
							printf(
							// translators: 1. Terms and Condition URL, 2. Terms and Condition Title, 3. Privacy Policy URL, 4. Privacy Policy Title.
								wp_kses_post( __( 'I agree to the <a href="%1$s">%2$s</a> & <a href="%3$s">%4$s</a>', 'gigneo' ) ),
								esc_url( $terms_url ),
								esc_html( $terms_title ),
								esc_url( $privacy_url ),
								esc_html( $privacy_title )
							);
							?>
						</label>
					</div>
				</div>
			</fieldset>
		</div>
		<div class="gn-footer">
			<input type="hidden" name="per_credit_rate" value="<?php echo esc_attr( $credit_rate ); ?>">
			<button type="submit" class="gn-btn gn-btn-md gn-btn-block gn-btn-primary"><?php echo esc_html__( 'Buy now', 'gigneo' ); ?></button>
		</div>
	</form>
</div>