<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
$job_id            = ! empty( $args['p_id'] ) ? $args['p_id'] : 0;
$proposal_id       = ! empty( $args['proposal_id'] ) ? $args['proposal_id'] : 0;
$current_step      = $args['current_step'] ?? 'basic';
$redirect_url      = $args['redirect_url'] ?? '';
$profile_id        = gigneo_active_profile_id();
$available_credits = gigneo_available_credits( $profile_id );
$apply_type        = gigneo_option( '_gigneo_ts_job_apply_type' );
$apply_credits     = gigneo_option( '_gigneo_ts_job_apply_credits', '10' );
$privacy_page_id   = gigneo_option( '_gigneo_ts_job_privacy_policy' );
$terms_page_id     = gigneo_option( '_gigneo_ts_job_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' );
?>
<!--Publish proposal -->
<div id="gn-proposal-publish" class="gn-modal-wrapper gn-proposal-publish-modal">
	<div class="gn-modal-dialog">
		<div class="gn-modal-content">
			<div class="gn-modal-info">
				<div class="gn-modal-header">
					<h4 class="gn-title"><?php echo esc_html__( 'Submit proposal', 'gigneo' ); ?></h4>
					<p class="gn-description"><?php echo esc_html__( 'You’re about to submit this proposal.', 'gigneo' ); ?></p>
					<button type="button" data-gn-modal-close="gn-proposal-publish" class="gn-modal-close">
						<i class="hi hi-x-mark" aria-hidden="true"></i>
					</button>
				</div>
				<form id="gn-proposal-publish-form" class="gn-theme-form gn-proposal-publish-form">
					<div class="gn-modal-body gn-custom-scrollbar">
						<?php if ( 'paid' === $apply_type ) { ?>
							<div class="gn-credits-info">
								<div class="gn-heading-area">
									<h6 class="gn-title">
										<i class="hi hi-wallet" aria-hidden="true"></i>
										<?php
										printf(
											// translators: %s credits
											esc_html__( '%s Credits required', 'gigneo' ),
											esc_html( $apply_credits )
										);
										?>
									</h6>
									<p class="gn-description">
										<?php
										printf(
											// translators: %s credits
											esc_html__( '%s credits will be deducted form your wallet to publish this proposal.', 'gigneo' ),
											esc_html( $apply_credits )
										);
										?>
									</p>
								</div>
								<div class="gn-total-credits">
									<span class="gn-label"><?php echo esc_html__( 'Available credits', 'gigneo' ); ?></span>
									<span class="gn-value"><?php echo esc_html( $available_credits ); ?></span>
								</div>
								<?php if ( $available_credits > intval( $apply_credits ) ) { ?>
									<div class="gn-remaining-credits">
										<span class="gn-label"><?php echo esc_html__( 'Remaining balance', 'gigneo' ); ?></span>
										<span class="gn-value"><?php echo esc_html( $available_credits - $apply_credits ); ?></span>
									</div>
								<?php } ?>
							</div>
						<?php } ?>
						<fieldset class="gn-form-fields gn-footer-terms-fields">
					<div class="gn-form-field">
						<div class="gn-form-field-checkbox">
							<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>"/>
							<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-modal-footer">
						<button type="button" class="gn-btn gn-btn-outline-grey" data-gn- data-gn-modal-close="gn-proposal-publish"><?php echo esc_html__( 'Close', 'gigneo' ); ?></button>
						<button type="submit" data-gn-redirect-url="<?php echo esc_url( $redirect_url ); ?>" class="gn-btn gn-btn-primary" data-gn-type="publish">
							<?php echo esc_html__( 'Submit', 'gigneo' ); ?>
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
