<?php
if (!empty($_POST['url'])){
	ihc_add_new_redirect_link($_POST);
} else if (isset($_POST['delete_redirect_link'])){
	ihc_delete_redirect_link($_POST['delete_redirect_link']);
}
?>
<div class="iump-wrapper">
<form method="post"  id="redirect_links_form">
	<input type="hidden" value="" name="delete_redirect_link" id="delete_redirect_link" />
	<div class="ihc-stuffbox">
		<h3><?php esc_html_e('Redirect Links', 'ihc');?></h3>
		<div class="inside">
		<h2><?php esc_html_e('Redirect Links', 'ihc');?></h2>
		<p><?php esc_html_e('Add custom links from inside or outside of your website that can be used for redirects inside the membership system.', 'ihc');?></p>
		<div class="iump-form-line">
			<div class="row">
				<div class="col-xs-5">
					<div class="input-group">
						<span class="input-group-addon" id="basic-addon1"><?php esc_html_e('Name:', 'ihc');?></span>
						<input type="text" class="form-control" name="name"value="" />
					</div>
				</div>
				</div>
			</div>
			<div class="iump-form-line">
			<div class="row">
				<div class="col-xs-5">
					<div class="input-group">
						<span class="input-group-addon" id="basic-addon1"><?php esc_html_e('Custom Link:', 'ihc');?></span>
						<input type="text" class="form-control" name="url"value="" />
					</div>
				</div>
				</div>
			</div>

			<div class="ihc-submit-form">
				<input type="submit" value="<?php esc_html_e('Add New', 'ihc');?>" name="ihc_save" class="button button-primary button-large" />
			</div>
		</div>
	</div>
</form>
<?php
$data = get_option('ihc_custom_redirect_links_array');
if ($data && count($data)){
	?>
	<div class="ihc-dashboard-form-wrap">
		<table class="wp-list-table widefat fixed tags ihc-admin-tables">
			<thead>
				<tr>
					<th class="manage-column"><?php esc_html_e('Name', 'ihc');?></th>
					<th class="manage-column"><?php esc_html_e('Link', 'ihc');?></th>
					<th class="manage-column" width="50px"><?php esc_html_e('Delete', 'ihc');?></th>
				</tr>
			</thead>
			<?php
				$i = 1;
				foreach ($data as $key=>$url){
				?>
				<tr class="<?php if ($i%2==0){
					 echo 'alternate';
				}
				?>
				">
					<td><?php echo $key;?></td>
					<td><a href="<?php echo $url;?>" target="_blank"><?php echo $url;?></a></td>
					<td align="center">
						<i class="fa-ihc ihc-icon-remove-e ihc-js-admin-redirect-links-do-delete" data-key="<?php echo $key;?>" ></i>
					</td>
				</tr>
				<?php
				$i++;
				}
				?>
		</table>
	</div>
<?php
}
?>
</div>
<?php
