<?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;

$bid_amount      = gigneo_post_meta( $proposal_id, '_gigneo_pm_budget' );
$duration_length = gigneo_post_meta( $proposal_id, '_gigneo_pm_duration' );
$duration_type   = gigneo_post_meta( $proposal_id, '_gigneo_pm_duration_type' );

$template_args = array(
	'job_id'      => $job_id,
	'proposal_id' => $proposal_id,
);
?>

<div class="gn-section gn-terms">
	<div class="gn-head">
		<h2 class="gn-title"><?php esc_html_e( 'Proposal terms', 'gigneo' ); ?></h2>
		<p class="gn-description">
			<?php esc_html_e( 'Define your bid amount and estimated timeline for this project.', 'gigneo' ); ?></p>
	</div>
	<div class="gn-body">
		<fieldset class="gn-form-fields gn-terms-fields">
			<div class="gn-form-field gn-proposal-fields">
				<label for="gn-bid-amount" class="gn-required-field-label">
					<?php echo esc_html__( 'Bid amount', 'gigneo' ); ?>
				</label>
				<input type="number" id="gn-bid-amount" name="bid_amount" class="gn-required-field"
					autocomplete="off" value="<?php echo esc_attr( $bid_amount ); ?>" />
			</div>
			<div class="gn-form-field gn-select2 gn-pricing-fields">
				<label for="gn-duration-length" class="gn-required-field-label">
					<?php echo esc_html__( 'Duration length', 'gigneo' ); ?>
				</label>
				<input type="number" name="duration_length" id="gn-duration-length" class="gn-required-field" value="<?php echo esc_attr( $duration_length ); ?>" />
			</div>
			<div class="gn-form-field gn-select2 gn-pricing-fields">
				<label for="gn-duration" class="gn-required-field-label">
					<?php echo esc_html__( 'Duration type', 'gigneo' ); ?>
				</label>
				<span class="gn-select">
					<select type="text" name="duration" id="gn-duration" class="gn-required-field" tabindex="-1"
						aria-hidden="true">
						<?php
						$duration_options = gigneo_delivery_time_types();
						foreach ( $duration_options as $key => $value ) {
							echo '<option value="' . esc_attr( $key ) . '" ' . selected( $duration_type, $key, false ) . '>'
									. esc_html( $value ) .
									'</option>';
						}
						?>
					</select>
				</span>
			</div>
		</fieldset>
	</div>
</div>