<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$p_id            = $args['p_id'] ?? 0;
$current_step    = $args['current_step'] ?? 'basic';
$redirect_url    = $args['redirect_url'] ?? '';
$budget          = ! empty( $p_id ) ? gigneo_post_meta( $p_id, '_gigneo_pm_price' ) : '';
$duration        = ! empty( $p_id ) ? gigneo_post_meta( $p_id, '_gigneo_pm_duration_type' ) : '';
$duration_length = ! empty( $p_id ) ? gigneo_post_meta( $p_id, '_gigneo_pm_duration' ) : '';

?>
<div id="gn-job-edit-pricing"
	class="gn-job-edit-step gn-job-edit-pricing <?php echo esc_attr( 'pricing' !== $current_step ? ' d-none' : '' ); ?>">
	<div class="row gy-4">
		<div class="col-lg-8 col-xl-9 order-2 order-lg-1">
			<form id="gn-job-form-pricing" class="gn-main gn-job-edit-form">
				<div class="gn-edit-job-section gn-budget-section">
					<div class="gn-body">
						<div class="gn-form-fields">
							<div class="gn-form-field gn-pricing-fields gn-buget-field">
								<label for="gn-job-budget" class="gn-required-field-label">
									<?php echo esc_html__( 'Total budget', 'gigneo' ); ?>
								</label>
								<input type="number" id="gn-job-budget" name="budget" class="gn-required-field" value="<?php echo esc_attr( $budget ); ?>" autocomplete="off" />
							</div>
						</div>
					</div>
				</div>
				<div class="gn-edit-job-section gn-duration-section">
					<div class="gn-head">
						<div class="gn-heading-area">
							<h3 class="gn-title"><?php echo esc_html__( 'Timeline', 'gigneo' ); ?></h3>
							<p class="gn-description">
								<?php echo esc_html__( 'Specify the delivery timeline you expect.', 'gigneo' ); ?>
							</p>
						</div>
					</div>
					<div class="gn-body">
						<div class="gn-form-fields gn-duration-fields">
							<div class="row gy-4">
								<div class="col-md-6">
									<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>
								<div class="col-md-6">
									<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>
										<select type="text" name="duration" id="gn-duration" class="gn-required-field">
											<?php
											$duration_options = gigneo_delivery_time_types( '', false );
											foreach ( $duration_options as $key => $value ) {
												?>
												<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $duration, $key ); ?>><?php echo esc_html( $value ); ?></option>
												<?php
											}
											?>
										</select>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="gn-edit-job-footer gn-actions">
					<button type="button" data-gn-step="pricing" data-gn-type="draft" data-gn-redirect-url="<?php echo esc_url( $redirect_url ); ?>"
						class="gn-btn gn-btn-outline-grey gn-job-save"><?php echo esc_html__( 'Save as draft', 'gigneo' ); ?></button>
					<button type="button" data-gn-step="pricing" data-gn-prev-step="basic"
						class="gn-btn gn-btn-outline-grey gn-job-back">
						<?php echo esc_html__( 'Back', 'gigneo' ); ?>
					</button>
					<button type="button" data-gn-step="pricing" data-gn-type="continue" data-gn-next-step="details"
						class="gn-btn gn-btn-primary gn-job-save">
						<?php echo esc_html__( 'Continue', 'gigneo' ); ?>
					</button>
				</div>
			</form>
		</div>
		<div class="col-lg-4 col-xl-3 order-1 order-lg-2">
			<div class="gn-aside">
				<div class="gn-aside-content">
					<h4 class="gn-title"><?php echo esc_html__( 'Pricing setup:', 'gigneo' ); ?></h4>
					<div class="gn-aside-body">
						<ul class="gn-list">
							<li><p class="gn-description"><?php echo esc_html__( 'Set a clear job budget to define how much will be paid for the project.', 'gigneo' ); ?></p></li>
							<li><p class="gn-description"><?php echo esc_html__( 'Set a clear project timeline to align expectations on deadlines.', 'gigneo' ); ?></p></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>