<?php
/**
 * Payment Token Editor Template
 *
 * @package FunnelKit_Square
 * @subpackage Admin
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<tr>

	<th><?php echo esc_html( $title ); ?></th>

	<td class="forminp">

		<table class="fkwcsq_payment_gateway_token_editor widefat" data-gateway-id="<?php echo esc_attr( $id ); ?>" data-wpnonce="<?php echo esc_attr( wp_create_nonce( 'update-user_' . $user_id ) ); ?>">

			<thead>
				<tr>

					<?php
					// Display a column for each token field
					foreach ( $columns as $column_id => $column_title ) :
						?>
						<th class="token-<?php echo esc_attr( $column_id ); ?>"><?php echo esc_html( $column_title ); ?></th>
					<?php endforeach; ?>

				</tr>
			</thead>

			<tbody class="tokens">

				<?php
				/** Fire inside the payment gateway token editor.
				 *
				 * @since 1.1.0
				 * @param int $user_id the current user ID
				 */
				do_action( 'fkwcsq_square_token_editor_tokens', $user_id );
				?>

			</tbody>

			<tbody class="meta">
				<tr class="no-tokens" style="display: none;">
					<td colspan="<?php echo count( $columns ); ?>"><?php esc_html_e( 'No saved payment tokens', 'funnelkit-payment-gateway-square-for-woocommerce' ); ?></td>
				</tr>
			</tbody>

			<?php
			// Editor actions
			if ( ! empty( $actions ) ) :
				?>

				<tfoot>
					<tr>
						<th class="actions" colspan="<?php echo count( $columns ); ?>">

							<?php foreach ( $actions as $action_key => $label ) : ?>

									<?php $button_class = 'save' === $action_key ? 'button-primary' : 'button'; ?>

									<button class="fkwcsq-payment-gateway-token-editor-action-button <?php echo sanitize_html_class( $button_class ); ?>" data-action="<?php echo esc_attr( $action_key ); ?>" data-user-id="<?php echo esc_attr( $user_id ); ?>">
										<?php echo esc_attr( $label ); ?>
									</button>

							<?php endforeach; ?>

						</th>
					</tr>
				</tfoot>

			<?php endif; ?>

		</table>

	</td>

</tr>
