<?php if (empty($ajax)) : ?>
	<div class="wrap newsletters">
		<h1><?php _e('Create Subscribe Form', 'wp-mailinglist'); ?></h1>
		<div style="min-width:400px;" id="newsletters_forms_createform_wrapper">
<?php endif; ?>
		<?php
			
		if ($this -> language_do()) {
			$languages = $this -> language_getlanguages();
		}	
			
		?>

		<?php $this -> render('error', array('errors' => $errors), true, 'admin'); ?>

		<form onsubmit="newsletters_forms_createform(); return false;" action="<?php echo admin_url('admin-ajax.php?action=newsletters_forms_createform'); ?>" method="post" id="newsletters_forms_createform">
			<?php wp_nonce_field($this -> sections -> forms . '_createform'); ?>
			<p>
				<label for="Subscribeform_title" style="font-weight:bold;"><?php _e('Title', 'wp-mailinglist'); ?></label>
				<?php if ($this -> language_do()) : ?>
					<div id="title-tabs">
						<ul>
							<?php foreach ($languages as $language) : ?>
								<li><a href="#title-tabs-<?php echo $language; ?>"><?php echo $this -> language_flag($language); ?></a></li>
							<?php endforeach; ?>
						</ul>
						<?php foreach ($languages as $language) : ?>
							<div id="title-tabs-<?php echo $language; ?>">
								<input type="text" class="widefat" name="Subscribeform[title][<?php echo $language; ?>]" value="" id="Subscribeform_title_<?php echo $language; ?>" />
							</div>
						<?php endforeach; ?>
					</div>
					
					<script type="text/javascript">
					jQuery(document).ready(function() {
						if (jQuery.isFunction(jQuery.fn.tabs)) {
							jQuery('#title-tabs').tabs();
						}
					});
					</script>
				<?php else : ?>
					<input class="widefat" type="text" name="Subscribeform[title]" value="" id="Subscribeform_title" />
				<?php endif; ?>
			</p>
			
			<p class="submit">
				<button type="submit" value="1" id="newsletters_forms_createform_submit" name="createform" class="button button-primary">
					<span id="newsletters_forms_createform_loading" style="display:none;"><i class="fa-solid fa-arrows-rotate fa-spin"></i></span>
					<?php _e('Create Form', 'wp-mailinglist'); ?></button>
				</button>
			</p>
		</form>
<?php if (empty($ajax)) : ?>
		</div>
	</div>
<?php endif; ?>

<script type="text/javascript">
jQuery(document).ready(function() {
	jQuery.colorbox.resize();
	
	<?php if (!empty($success)) : ?>
		jQuery.colorbox.close(); 
		parent.location = '<?php echo admin_url('admin.php?page=' . $this -> sections -> forms . '&method=save&id=' . $this -> Subscribeform() -> insertid); ?>';
	<?php endif; ?>
	
	<?php if ($this -> language_do()) : ?>
		newsletters_focus('#Subscribeform_title_<?php echo $languages[0]; ?>');
	<?php else : ?>
		newsletters_focus('#Subscribeform_title');
	<?php endif; ?>
});

</script>