<?php
/**
 * View for Import Post Type Meta Box Import Options
 *
 * @since   1.2.0
 * @package feedzy-rss-feeds-pro
 */
?>
<div class="f1">

	<h3><?php echo __( 'Import Setup Wizard', 'feedzy-rss-feeds' ); ?></h3>
	<p><?php echo __( 'Follow the steps to setup an import rule.', 'feedzy-rss-feeds' ); ?></p>
	<div class="f1-steps">
		<div class="f1-progress">
			<div class="f1-progress-line" data-now-value="16.66" data-number-of-steps="3" style="width: 16.66%;"></div>
		</div>
		<div class="f1-step active">
			<div class="f1-step-icon"><span class="dashicons dashicons-rss"></span></div>
			<p><?php echo __( 'Sources', 'feedzy-rss-feeds' ); ?></p>
		</div>
		<div class="f1-step">
			<div class="f1-step-icon"><span class="dashicons dashicons-filter"></span></div>
			<p><?php echo __( 'Filters', 'feedzy-rss-feeds' ); ?></p>
		</div>
		<div class="f1-step">
			<div class="f1-step-icon"><span class="dashicons dashicons-randomize"></span></div>
			<p><?php echo __( 'Assign', 'feedzy-rss-feeds' ); ?></p>
		</div>
	</div>

	<fieldset>
		<h4><?php echo __( 'Feed sources:', 'feedzy-rss-feeds' ); ?></h4>
		<div class="form-group">
			<label class="feedzy-sr-only"><?php echo __( 'Feedzy RSS Feed sources (URL\'s comma separated or Feed Categories slug)', 'feedzy-rss-feeds' ); ?></label>
		</div>
		<div class="form-group input-group">
			<input type="text" name="feedzy_meta_data[source]" placeholder="<?php echo __( 'Source', 'feedzy-rss-feeds' ); ?>" class="form-control  " value="<?php echo $source; ?>"/>
			<div class="input-group-btn">
			<?php
			if ( isset( $feed_categories ) && ! empty( $feed_categories ) ) {
			?>
				<button type="button" class="btn btn-add-fields dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					<?php echo __( 'Add Feed Category', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-down-alt2"></span>
				</button>
				<div class="dropdown-menu dropdown-menu-right">
					<?php
					foreach ( $feed_categories as $category ) {
					?>
						<a class="dropdown-item source" href="#" data-field-name="source" data-field-tag="<?php echo $category->post_name; ?>"><?php echo $category->post_title; ?></a>
					<?php
					}
					?>
				</div>
			<?php
			} else {
				?>
				<button type="button" class="  disabled btn-add-fields btn "  >
					<?php echo __( 'No feed categories available', 'feedzy-rss-feeds' ); ?>
				</button>
				<?php

			}
			?>
			</div>
		</div>
		<div class="f1-buttons">
			<button type="button" class="btn btn-next"><?php echo __( 'Next', 'feedzy-rss-feeds' ); ?></button>
		</div>
	</fieldset>

	<fieldset>
		<h4><?php echo __( 'Feed filters:', 'feedzy-rss-feeds' ); ?></h4>
		<div class="form-group">
			<label class="feedzy-sr-only"><?php echo __( 'Only display item if title contains specific keyword(s) (comma-separated list/case sensitive).', 'feedzy-rss-feeds' ); ?></label>
			<input type="text" name="feedzy_meta_data[inc_key]" placeholder="<?php echo __( '(eg. news, sports etc.)', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $inc_key; ?>"/>
		</div>
		<div class="form-group">
			<label class="feedzy-sr-only"><?php echo __( 'Exclude items if title or content contains specific keyword(s) (comma-separated list/case sensitive).', 'feedzy-rss-feeds' ); ?></label>
			<input type="text" name="feedzy_meta_data[exc_key]" placeholder="<?php echo __( '(eg. news, sports etc.)', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $exc_key; ?>"/>
		</div>
		<div class="f1-buttons">
			<button type="button" class="btn btn-previous"><?php echo __( 'Previous', 'feedzy-rss-feeds' ); ?></button>
			<button type="button" class="btn btn-next"><?php echo __( 'Next', 'feedzy-rss-feeds' ); ?></button>
		</div>
	</fieldset>

	<fieldset>
		<h4><?php echo __( 'Feed assign:', 'feedzy-rss-feeds' ); ?></h4>
		<p><?php echo __( 'Map post elements to custom post from feed imports.', 'feedzy-rss-feeds' ); ?></p>
		<div class="col-left">
			<h5 style="text-align: center;"><?php echo __( 'Post Elements', 'feedzy-rss-feeds' ); ?></h5>
			<div class="label_description" style=" min-height: 75px;">
				<label class="feedzy-sr-only" for="f1-post-type"><?php echo __( 'Post Type', 'feedzy-rss-feeds' ); ?></label><br/>
				<small>
					<?php
					echo __( 'The post type you want to use for the generated post. And if needed the Taxonomy term (eg. "Category", "Tags" etc.)', 'feedzy-rss-feeds' );
					?>
				</small>
			</div>
			<div class="label_description">
				<label class="feedzy-sr-only" for="f1-post-title"><?php echo __( 'Post Title', 'feedzy-rss-feeds' ); ?></label><br/>
				<small>
				<?php
				echo __( 'The title for the generated post. You can use ', 'feedzy-rss-feeds' ) .
					'<b>[#item_title]</b>, <b>[#title_wordai]</b>, <b>[#item_author]</b>, <b>[#item_date]</b>' .
					__( ' tags to append the feed item title to the generated post title or mix and match your own.', 'feedzy-rss-feeds' );
				?>
				</small>
			</div>
			<div class="label_description">
				<label class="feedzy-sr-only" for="f1-post-title"><?php echo __( 'Post Date', 'feedzy-rss-feeds' ); ?></label><br/>
				<small>
					<?php
					echo __( 'The date for the generated post. You can use ', 'feedzy-rss-feeds' ) .
						'<b>[#item_date]</b>, <b>[#post_date]</b>' .
						__( ' tags or leave blank.', 'feedzy-rss-feeds' );
					?>
				</small>
			</div>
			<div class="label_description" style="height: 115px;">
				<label class="feedzy-sr-only" for="f1-post-content"><?php echo __( 'Item Content', 'feedzy-rss-feeds' ); ?></label><br/>
				<small>
				<?php
				echo __( 'The content for the generated post. You can use ', 'feedzy-rss-feeds' ) .
					'<b>[#item_content]</b>, <b>[#content_wordai]</b>, <b>[#item_image]</b>' .
					__( ' tags to append the feed item content for the generated post content.', 'feedzy-rss-feeds' );
				?>
				</small>
			</div>
			<div class="label_description">
				<label class="feedzy-sr-only" for="f1-post-content"><?php echo __( 'Featured Image', 'feedzy-rss-feeds' ); ?></label><br/>
				<small>
					<?php
					echo __( 'The URL for the featured image. You can use ', 'feedzy-rss-feeds' ) .
						'<b>[#item_image]</b>' .
						__( ' tag, use your own URL or leave it empty. (*optional)', 'feedzy-rss-feeds' );
					?>
				</small>
			</div>
		</div>
		<div class="col-right">
			<h5 style="text-align: center;"><?php echo __( 'To Custom Post', 'feedzy-rss-feeds' ); ?></h5>
			<div class="form-group input-group form_item" style="width: 100%; min-height: 50px;">
				<select id="feedzy_post_type" class="form-control" name="feedzy_meta_data[import_post_type]" data-tax="<?php echo $import_post_term; ?>" >
					<?php
					foreach ( $post_types as $post_type ) {
						$selected = '';
						if ( $post_type == $import_post_type ) {
							$selected = 'selected';
						}
					?>
						<option value="<?php echo $post_type; ?>" <?php echo $selected; ?>><?php echo $post_type; ?></option>
					<?php
					}
					?>
				</select>
				<select id="feedzy_post_terms" class="form-control" name="feedzy_meta_data[import_post_term]" >

				</select>
			</div>
			<div class="form-group input-group form_item">
				<input type="text" name="feedzy_meta_data[import_post_title]" placeholder="<?php echo __( 'Post Title', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $import_title; ?>"/>
				<div class="input-group-btn">
					<button type="button" class="btn btn-add-fields dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<?php echo __( 'Insert Tag', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-down-alt2"></span>
					</button>
					<div class="dropdown-menu dropdown-menu-right">
						<a class="dropdown-item" href="#" data-field-name="import_post_title" data-field-tag="item_title"><?php echo __( 'Item Title', 'feedzy-rss-feeds' ) . ' -- <small>[#item_title]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_title" data-field-tag="title_wordai"><?php echo __( 'Title from WordAI', 'feedzy-rss-feeds' ) . ' -- <small>[#title_wordai]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_title" data-field-tag="item_author"><?php echo __( 'Item Author', 'feedzy-rss-feeds' ) . ' -- <small>[#item_author]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_title" data-field-tag="item_date"><?php echo __( 'Item Date', 'feedzy-rss-feeds' ) . ' -- <small>[#item_date]</small>'; ?></a>
					</div>
				</div>
			</div>
			<div class="form-group input-group form_item">
				<input type="text" name="feedzy_meta_data[import_post_date]" placeholder="<?php echo __( 'Post Date', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $import_date; ?>"/>
				<div class="input-group-btn">
					<button type="button" class="btn btn-add-fields dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<?php echo __( 'Insert Tag', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-down-alt2"></span>
					</button>
					<div class="dropdown-menu dropdown-menu-right">
						<a class="dropdown-item" href="#" data-field-name="import_post_date" data-field-tag="item_date"><?php echo __( 'Item Date', 'feedzy-rss-feeds' ) . ' -- <small>[#item_date]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_date" data-field-tag="post_date"><?php echo __( 'Post Date', 'feedzy-rss-feeds' ) . ' -- <small>[#post_date]</small>'; ?></a>
					</div>
				</div>
			</div>
			<div class="form-group input-group form_item">
				<textarea name="feedzy_meta_data[import_post_content]" placeholder="<?php echo __( 'Post Content', 'feedzy-rss-feeds' ); ?>" class="form-control"><?php echo $import_content; ?></textarea>
				<div class="input-group-btn">
					<button type="button" class="btn btn-add-fields dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<?php echo __( 'Insert Tag', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-down-alt2"></span>
					</button>
					<div class="dropdown-menu dropdown-menu-right">
						<a class="dropdown-item" href="#" data-field-name="import_post_content" data-field-tag="item_content"><?php echo __( 'Item Content', 'feedzy-rss-feeds' ) . ' -- <small>[#item_content]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_content" data-field-tag="content_wordai"><?php echo __( 'Content from WordAI', 'feedzy-rss-feeds' ) . ' -- <small>[#content_wordai]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_content" data-field-tag="item_image"><?php echo __( 'Item Image', 'feedzy-rss-feeds' ) . ' -- <small>[#item_image]</small>'; ?></a>
						<a class="dropdown-item" href="#" data-field-name="import_post_content" data-field-tag="item_url"><?php echo __( 'Item URL', 'feedzy-rss-feeds' ) . ' -- <small>[#item_url]</small>'; ?></a>
					</div>
				</div>
			</div>
			<div class="form-group input-group form_item">
				<input type="text" name="feedzy_meta_data[import_post_featured_img]" placeholder="<?php echo __( 'Featured Image', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $import_featured_img; ?>"/>
				<div class="input-group-btn">
					<button type="button" class="btn btn-add-fields dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
						<?php echo __( 'Insert Tag', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-arrow-down-alt2"></span>
					</button>
					<div class="dropdown-menu dropdown-menu-right">
						<a class="dropdown-item" href="#" data-field-name="import_post_featured_img" data-field-tag="item_image"><?php echo __( 'Item Image', 'feedzy-rss-feeds' ) . ' -- <small>[#item_image]</small>'; ?></a>
					</div>
				</div>
			</div>
		</div>

		<hr style="clear: both" />
		<div class="custom_fields">
			<!-- Custom Fields Added By JS -->
			<?php
			if ( isset( $import_custom_fields ) && ! empty( $import_custom_fields ) ) {
				foreach ( $import_custom_fields as $custom_field_key => $custom_field_value ) {
					?>
					<div class="row">
						<div class="col-left fields">
							<div class="form-group form_item">
								<input type="text" name="custom_vars_key[]" placeholder="<?php echo __( 'Key Name', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $custom_field_key; ?>"/>
							</div>
						</div>
						<div class="col-right">
							<div class="form-group input-group form_item">
								<input type="text" name="custom_vars_value[]" placeholder="<?php echo __( 'Value', 'feedzy-rss-feeds' ); ?>" class="form-control" value="<?php echo $custom_field_value; ?>"/>
								<div class="input-group-btn">
									<button type="button" class="btn btn-remove-fields">
										<span class="dashicons dashicons-trash"></span>
									</button>
								</div>
							</div>
						</div>
					</div>
					<?php
				}
			}
			?>
		</div>

		<button id="new_custom_fields" type="button" class="btn btn-add-fields" style="width: 100%; margin-bottom: 16px; margin-top: 16px;" ><?php echo __( 'Add custom fields', 'feedzy-rss-feeds' ); ?> <span class="dashicons dashicons-plus-alt"></span></button>
		<div class="f1-buttons">
			<input type="hidden" id="custom_post_status" name="custom_post_status" value="draft" />
			<button type="button" class="btn btn-previous"><?php echo __( 'Previous', 'feedzy-rss-feeds' ); ?></button>
			<?php
			if ( $post_status == 'publish' ) {
			?>
				<button type="submit" name="publish" class="btn btn-submit" value="Publish"><?php echo __( 'Save', 'feedzy-rss-feeds' ); ?></button>
			<?php
			} else {
			?>
				<button type="submit" name="save" class="btn btn-submit" value="Save Draft" style="float: none;"><?php echo __( 'Save', 'feedzy-rss-feeds' ); ?></button>
				<button type="submit" name="publish" class="btn btn-submit btn-activate" value="Publish" ><?php echo __( 'Save & Activate', 'feedzy-rss-feeds' ); ?></button>
			<?php
			}
			?>
		</div>
	</fieldset>
</div>

<script id="empty_select_tpl" type="text/template">
	<option value="none"><?php echo __( 'None', 'feedzy-rss-feeds' ); ?></option>
</script>

<script id="new_field_tpl" type="text/template">
	<div class="row">
		<div class="col-left fields">
			<div class="form-group form_item">
				<input type="text" name="custom_vars_key[]" placeholder="<?php echo __( 'Key Name', 'feedzy-rss-feeds' ); ?>" class="form-control">
			</div>
		</div>
		<div class="col-right">
			<div class="form-group input-group form_item">
				<input type="text" name="custom_vars_value[]" placeholder="<?php echo __( 'Value', 'feedzy-rss-feeds' ); ?>" class="form-control">
				<div class="input-group-btn">
					<button type="button" class="btn btn-remove-fields">
						<span class="dashicons dashicons-trash"></span>
					</button>
				</div>
			</div>
		</div>
	</div>
</script>
