<?php 
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals

defined( 'ABSPATH' ) || exit;

?>
<div class="wfdp-donation-input-form wfdp-input-payment-field-wraper <?php echo esc_attr( $wfpEnableDisplayField ); ?>">
	<div class="wfdp-input-payment-field">
		<?php echo wp_kses( do_action( 'wfp_donate_forms_payment_method_headding_before' ), \WfpFundraising\Utilities\Utils::get_kses_array() ); ?>
		<span class=""> <?php echo wp_kses( apply_filters( 'wfp_donate_forms_payment_method_headding', esc_html__( 'Select Payment Method:', 'wp-fundraising-donation' ) ), \WfpFundraising\Utilities\Utils::get_kses_array() ); ?></span>
		<?php echo wp_kses( do_action( 'wfp_donate_forms_payment_method_headding_after' ), \WfpFundraising\Utilities\Utils::get_kses_array() ); ?>

		<ul class="xs-donate-display-amount wfp-radio-input-style-2">
		<?php
		$wfpOptionsData = isset( $wfpGateWaysData['services'] ) ? $wfpGateWaysData['services'] : array();

		if ( ! empty( $wfpOptionsData ) && is_array( $wfpOptionsData ) ) {
			$wfp_m = 0;
			foreach ( $wfpOptionsData as $wfp_key => $payment ) :
				if ( isset( $wfpOptionsData[ $wfp_key ]['enable'] ) && $wfpOptionsData[ $wfp_key ]['enable'] == 'Yes' ) :
					$wfpDefultCheck = '';
					if ( $wfp_m == 0 ) {
						$wfpDefultCheck = 'checked';
					}

					$wfpInfoData = isset( $wfpOptionsData[ $wfp_key ]['setup'] ) ? $wfpOptionsData[ $wfp_key ]['setup'] : array();

					?>
						<li>
							<input class="xs_radio_filed" id="wfp_<?php echo esc_attr( isset( $wfpInfoData['title'] ) ? str_replace( ' ', '_', strtolower( $wfpInfoData['title'] ) ) : '' ); ?>" type="radio" name="xs_donate_data_submit[payment_method]" <?php echo esc_attr( $wfpDefultCheck ); ?> value="<?php echo esc_attr( $wfp_key ); ?>" onchange="xs_show_hide_multiple_div('.payment_method_info', '.method-<?php echo esc_attr( $wfp_key ); ?>');"> 
							<label for="wfp_<?php echo esc_attr( isset( $wfpInfoData['title'] ) ? str_replace( ' ', '_', strtolower( $wfpInfoData['title'] ) ) : '' ); ?>"><?php echo esc_attr( isset( $wfpInfoData['title'] ) ? $wfpInfoData['title'] : '' ); ?></label>
						</li>
					<?php
					$wfp_m++;
				endif;
			endforeach;
		} else {
			echo wp_kses( '<p> ' . __( 'Set Payment Method', 'wp-fundraising-donation' ) . ' </p>', \WfpFundraising\Utilities\Utils::get_kses_array() );
		}
		?>
		</ul>
	</div>
</div>
<div class="wfdp-input-payment-field wfdp-donation-payment-details <?php echo esc_attr( $wfpEnableDisplayField ); ?>">
	<div class="xs-donate-display-amount">
	<?php
	$wfp_m = 0;
	foreach ( $wfpOptionsData as $wfp_key => $payment ) :
		if ( isset( $wfpOptionsData[ $wfp_key ]['enable'] ) && $wfpOptionsData[ $wfp_key ]['enable'] == 'Yes' ) :
			$wfpDefultCheck = '';
			if ( $wfp_m == 0 ) {
				$wfpDefultCheck = 'yes';
			}

			$wfpInfoData = isset( $wfpOptionsData[ $wfp_key ]['setup'] ) ? $wfpOptionsData[ $wfp_key ]['setup'] : array();

			?>
			<div class="payment_method_info method-<?php echo esc_attr( $wfp_key ); ?> xs-donate-hidden <?php echo ( $wfpDefultCheck == 'yes' ) ? 'xs-donate-visible' : ''; ?>">
				<h2 class="wfp-payment-method-title fdas"><?php echo esc_attr( isset( $wfpInfoData['title'] ) ? $wfpInfoData['title'] : '' ); ?> </h2>
			<?php
			if ( $wfp_key == 'bank_payment' ) {
				$wfpSetupData = isset( $arrayPayment[ $wfp_key ]['setup']['account_details'] ) ? $arrayPayment[ $wfp_key ]['setup']['account_details'] : array();
				?>
			<div> <strong> <?php echo esc_html__( 'Account Details:', 'wp-fundraising-donation' ); ?></strong></div>
				<?php
				if ( isset( $wfpInfoData['account_details'] ) ) {
					?>
					<div class="xs-table-responsive wfdp-table-design">
						<table class="form-table wc_gateways widefat payment-details">
							<thead>
								<tr>
									<th>SL.</th>
							<?php
							foreach ( $wfpSetupData as $wfpSubKeyHead => $setupDetails ) :
								$wfpLabelNameSub = ucfirst( str_replace( array( '_', '-' ), ' ', $wfpSubKeyHead ) );
								?>
								<th class="name"> <?php echo esc_html( $wfpLabelNameSub ); ?></th>
								<?php
							endforeach;
							?>
								</tr>
							</thead>
							<tbody>
							
							<?php
							$wfp_mm = 1;
							foreach ( $wfpInfoData['account_details'] as $wfp_account ) :
								?>
								<tr>
									<td><?php echo esc_attr( $wfp_mm ) . '. '; ?></td>
									<?php foreach ( $wfpSetupData as $wfpSubKeyHead => $setupDetails ) : ?>
										<td>
											<?php echo esc_html( $wfp_account[ $wfpSubKeyHead ] ); ?>
										</td>
									<?php endforeach; ?>
								</tr>
								<?php
								$wfp_mm++;
							endforeach;
							?>
							</tbody>
						</table>
					</div>
					<?php
				}
				?>
			
			
				<?php
			}
			if ( isset( $wfpInfoData['description'] ) && strlen( $wfpInfoData['description'] ) > 4 ) :
				?>
				<div class="wfp-payment-method-acc-details"> <strong class="wfp-payment-method-acc-details--title"><?php echo wp_kses( apply_filters( 'wfp_donate_forms_payment_method_details', esc_html__( 'Details:', 'wp-fundraising-donation' ) ), \WfpFundraising\Utilities\Utils::get_kses_array() ); ?></strong>
					<span class="wfp-payment-method-acc-details--description"><?php echo esc_html( isset( $wfpInfoData['description'] ) ? $wfpInfoData['description'] : '' ); ?></span>
				</div>
				<?php
			endif;
			if ( isset( $wfpInfoData['instructions'] ) && strlen( $wfpInfoData['instructions'] ) > 4 ) :
				?>
				<div class="wfp-payment-method-acc-details"> <strong class="wfp-payment-method-acc-details--title"><?php echo wp_kses( apply_filters( 'wfp_donate_forms_payment_method_instructions', esc_html__( 'Instructions:', 'wp-fundraising-donation' ) ), \WfpFundraising\Utilities\Utils::get_kses_array() ); ?></strong>
					<span class="wfp-payment-method-acc-details--description"><?php echo esc_html( isset( $wfpInfoData['instructions'] ) ? $wfpInfoData['instructions'] : '' ); ?></span>
				</div>
			<?php endif; ?>
			</div>
			<?php
			$wfp_m++;
		endif;
	endforeach;
	?>
	</div>
</div>
