{{ header }}{{ column_left }} 
<div id="content"><div class="container-fluid">
	<div class="page-header">
	    <h1>Newsletter</h1>
	    <ul class="breadcrumb">
		     {% for breadcrumb in breadcrumbs %} 
		      <li><a href="{{ breadcrumb['href'] }}">{{ breadcrumb['text'] }}</a></li>
		      {% endfor %} 
	    </ul>
	  </div>
    
    <link href='https://fonts.googleapis.com/css?family=Poppins:700,600,500,400,300' rel='stylesheet' type='text/css'>
    
	{% if (error_warning) %} 
		<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }} 
		  <button type="button" class="close" data-dismiss="alert">&times;</button>
		</div>
	{% elseif (success) %} 
		<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> {{ success }} 
			<button type="button" class="close" data-dismiss="alert">&times;</button>
		</div>
	{% endif %} 
	  
	<script type="text/javascript">
	$.fn.tabs = function() {
		var selector = this;
		
		this.each(function() {
			var obj = $(this); 
			
			$(obj.attr('href')).hide();
			
			$(obj).click(function() {
				$(selector).removeClass('selected');
				
				$(selector).each(function(i, element) {
					$($(element).attr('href')).hide();
				});
				
				$(this).addClass('selected');
				
				$($(this).attr('href')).show();
				
				return false;
			});
		});
	
		$(this).show();
		
		$(this).first().click();
	};
	</script>

	<!-- Newsletter -->
	<div class="set-size" id="newsletter">		
		<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form">
			<!-- Content -->
			<div class="content">
				<div>
					<div class="bg-tabs clearfix">
						<div id="tabs">
                            <a href="{{ placement }}" id="placement" class="active"><span>Module<br> placement</span></a>
                            <a href="{{ settings }}" id="existing"><span>Translation<br> text</span></a>
                            <a href="{{ list_subscribed }}" id="subscribed"><span>List<br> subscribers</span></a>
                            <a href="{{ send_mail }}" id="existing"><span>Send<br> mail</span></a>
						</div>

						<div class="tab-content2">
							
							<div id="newsletter_modules" class="tabs_add_element clearfix">
                                <div class="column_add_head">Add<br> Newsletter</div>
								{% set i = 1 %} 
								{% for module in modules %} 
									<a href="#newsletter_module_{{ i }}" id="element_{{ i }}">{{ i }} &nbsp;<img src="view/image/module_template/delete-slider.png" alt="" onclick="$('#element_{{ i }}').remove(); $('#newsletter_modules a:first').trigger('click'); $('#newsletter_module_{{ i }}').remove(); return false;" /></a>
								{% set i = i + 1 %} 
								{% endfor %} 
								<img src="view/image/module_template/add.png" alt="" onclick="addModule();">
							</div>
							
							{% set i = 1 %} 
							{% for module in modules %} 
							<div id="newsletter_module_{{ i }}" style="padding-top:20px">
								<div id="language_{{ i }}" class="htabs">
									{% for language in languages %} 
									<a href="#tab_language_{{ i }}_{{ language['language_id'] }}"><img src="language/{{ language['code'] }}/{{ language['code'] }}.png" title="{{ language['name'] }}" /> {{ language['name'] }}</a>
									{% endfor %} 
								</div>
								
								{% for language in languages %} 
								<div id="tab_language_{{ i }}_{{ language['language_id'] }}">
									<div class="input clearfix">
										<p>Module Title:</p>
										<input type="text" name="newsletter_module[{{ i }}][{{ language['language_id'] }}][module_title]" value="{{ module[language['language_id']]['module_title'] is defined ? module[language['language_id']]['module_title'] : '' }}" />
									</div>
								
									<div class="input clearfix">
										<p>Module Text:</p>
										<div style="width: 608px;float: left"><textarea rows="0" cols="0" id="newsletter_module_{{ i }}_{{ language['language_id'] }}_html" name="newsletter_module[{{ i }}][{{ language['language_id'] }}][module_text]">{{ module[language['language_id']]['module_text'] is defined ? module[language['language_id']]['module_text'] : '' }}</textarea></div>
									</div>
								
									<div class="input clearfix">
										<p>Input Placeholder:</p>
										<input type="text" name="newsletter_module[{{ i }}][{{ language['language_id'] }}][input_placeholder]" value="{{ module[language['language_id']]['input_placeholder'] is defined ? module[language['language_id']]['input_placeholder'] : '' }}" />
									</div>
								
									<div class="input clearfix">
										<p>Subscribe text:</p>
										<input type="text" name="newsletter_module[{{ i }}][{{ language['language_id'] }}][subscribe_text]" value="{{ module[language['language_id']]['subscribe_text'] is defined ? module[language['language_id']]['subscribe_text'] : '' }}" />
									</div>
									
									<div class="input clearfix">
										<p>Unsubscribe text:</p>
										<input type="text" name="newsletter_module[{{ i }}][{{ language['language_id'] }}][unsubscribe_text]" value="{{ module[language['language_id']]['unsubscribe_text'] is defined ? module[language['language_id']]['unsubscribe_text'] : '' }}" />
									</div>
								</div>
								{% endfor %} 
								
								<script type="text/javascript">
								     $('#language_{{ i }} a').tabs();
								</script>
								
								<table class="form">
									<tr>
									  <td>Button unsubscribe:</td>
									  <td><select name="newsletter_module[{{ i }}][button_unsubscribe]">
										    {% if (module['button_unsubscribe']) %} 
										    <option value="1" selected="selected">Enabled</option>
										    <option value="0">Disabled</option>
										    {% else %} 
										    <option value="1">Enabled</option>
										    <option value="0" selected="selected">Disabled</option>
										    {% endif %} 
									    </select>
									  </td>
									</tr>
								  <tr>
								    <td>Layout:</td>
								    <td><select name="newsletter_module[{{ i }}][layout_id]">
								    	{% if (99999 == module['layout_id']) %} 
								    	<option value="99999" selected="selected">All pages</option>
								    	{% else %} 
								    	<option value="99999">All pages</option>
								    	{% endif %} 
								        {% for layout in layouts %} 
								        {% if (layout['layout_id'] == module['layout_id']) %} 
								        <option value="{{ layout['layout_id'] }}" selected="selected">{{ layout['name'] }}</option>
								        {% else %} 
								        <option value="{{ layout['layout_id'] }}">{{ layout['name'] }}</option>
								        {% endif %} 
								        {% endfor %} 
								      </select></td>
								  </tr>
								  <tr>
								    <td>Position:</td>
								    <td><select name="newsletter_module[{{ i }}][position]">
								    	{% if (module['position'] == 'menu') %} 
								    	<option value="menu" selected="selected">Menu</option>
								    	{% else %} 
								    	<option value="menu">Menu</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'slideshow') %} 
								    	<option value="slideshow" selected="selected">Slideshow</option>
								    	{% else %} 
								    	<option value="slideshow">Slideshow</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'preface_left') %} 
								    	<option value="preface_left" selected="selected">Preface left</option>
								    	{% else %} 
								    	<option value="preface_left">Preface left</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'preface_right') %} 
								    	<option value="preface_right" selected="selected">Preface right</option>
								    	{% else %} 
								    	<option value="preface_right">Preface right</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'preface_fullwidth') %} 
								    	<option value="preface_fullwidth" selected="selected">Preface fullwidth</option>
								    	{% else %} 
								    	<option value="preface_fullwidth">Preface fullwidth</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'column_left') %} 
								    	<option value="column_left" selected="selected">Column left</option>
								    	{% else %} 
								    	<option value="column_left">Column left</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'content_big_column') %} 
								    	<option value="content_big_column" selected="selected">Content big column</option>
								    	{% else %} 
								    	<option value="content_big_column">Content big column</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'content_top') %} 
								    	<option value="content_top" selected="selected">Content top</option>
								    	{% else %} 
								    	<option value="content_top">Content top</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'column_right') %} 
								    	<option value="column_right" selected="selected">Column right</option>
								    	{% else %} 
								    	<option value="column_right">Column right</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'content_bottom') %} 
								    	<option value="content_bottom" selected="selected">Content bottom</option>
								    	{% else %} 
								    	<option value="content_bottom">Content bottom</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'customfooter_top') %} 
								    	<option value="customfooter_top" selected="selected">CustomFooter Top</option>
								    	{% else %} 
								    	<option value="customfooter_top">CustomFooter Top</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'customfooter_bottom') %} 
								    	<option value="customfooter_bottom" selected="selected">CustomFooter Bottom</option>
								    	{% else %} 
								    	<option value="customfooter_bottom">CustomFooter Bottom</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'footer_top') %} 
								    	<option value="footer_top" selected="selected">Footer top</option>
								    	{% else %} 
								    	<option value="footer_top">Footer top</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'footer_left') %} 
								    	<option value="footer_left" selected="selected">Footer left</option>
								    	{% else %} 
								    	<option value="footer_left">Footer left</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'footer_right') %} 
								    	<option value="footer_right" selected="selected">Footer right</option>
								    	{% else %} 
								    	<option value="footer_right">Footer right</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'footer_bottom') %} 
								    	<option value="footer_bottom" selected="selected">Footer bottom</option>
								    	{% else %} 
								    	<option value="footer_bottom">Footer bottom</option>
								    	{% endif %} 
								    	{% if (module['position'] == 'bottom') %} 
								    	<option value="bottom" selected="selected">Bottom</option>
								    	{% else %} 
								    	<option value="bottom">Bottom</option>
								    	{% endif %} 
								      </select></td>
								  </tr>
								  <tr>
								    <td>Status:</td>
								    <td><select name="newsletter_module[{{ i }}][status]">
								        {% if (module['status']) %} 
								        <option value="1" selected="selected">Enabled</option>
								        <option value="0">Disabled</option>
								        {% else %} 
								        <option value="1">Enabled</option>
								        <option value="0" selected="selected">Disabled</option>
								        {% endif %} 
								      </select></td>
								  </tr>
								  <tr>
								    <td>Sort Order:</td>
								    <td><input type="text" name="newsletter_module[{{ i }}][sort_order]" value="{{ module['sort_order'] }}" size="3" /></td>
								  </tr>
								</table>
							</div>
							{% set i = i + 1 %} 
							{% endfor %} 
							
							<div id="newsletter_modules_add"></div>
							
							<script type="text/javascript">
								var module = {{ i }};
								function addModule() {
									html = '<div id="newsletter_module_' + module + '" style="padding-top:20px">';
									html += '  <div id="language_' + module + '" class="htabs">';
									{% for language in languages %} 
									html += '    <a href="#tab_language_'+ module + '_{{ language['language_id'] }}"><img src="language/{{ language['code'] }}/{{ language['code'] }}.png" title="{{ language['name'] }}" /> {{ language['name'] }}</a>';
									{% endfor %} 
									html += '  </div>';
									
									{% for language in languages %} 
									html += '    <div id="tab_language_'+ module + '_{{ language['language_id'] }}">';
									html += '		<div class="input clearfix">';
									html += '			<p>Module Title:</p>';
									html += '			<input type="text" name="newsletter_module[' + module + '][{{ language['language_id'] }}][module_title]" value="" />';
									html += '		</div>';
									
									html += '		<div class="input clearfix">';
									html += '			<p>Module Text:</p>';
									html += '			<div style="width: 608px;float: left"><textarea rows="0" cols="0" id="newsletter_module_' + module + '_{{ language['language_id'] }}_html" name="newsletter_module[' + module + '][{{ language['language_id'] }}][module_text]"></textarea></div>';
									html += '		</div>';
									
									html += '		<div class="input clearfix">';
									html += '			<p>Input Placeholder:</p>';
									html += '			<input type="text" name="newsletter_module[' + module + '][{{ language['language_id'] }}][input_placeholder]" value="" />';
									html += '		</div>';
									
									html += '		<div class="input clearfix">';
									html += '			<p>Subscribe text:</p>';
									html += '			<input type="text" name="newsletter_module[' + module + '][{{ language['language_id'] }}][subscribe_text]" value="" />';
									html += '		</div>';
									
									html += '		<div class="input clearfix">';
									html += '			<p>Unsubscribe text:</p>';
									html += '			<input type="text" name="newsletter_module[' + module + '][{{ language['language_id'] }}][unsubscribe_text]" value="" />';
									html += '		</div>';
									html += '    </div>';
									{% endfor %} 
									html += '  <table class="form">';
									html += '	<tr>';
									html += '		<td>Button unsubscribe:</td>';
									html += '      <td><select name="newsletter_module[' + module + '][button_unsubscribe]">';
									html += '        <option value="1">Enabled</option>';
									html += '        <option value="0" selected="selected=">Disabled</option>';
									html += '      </select></td>';
									html += '	</tr>';
									html += '    <tr>';
									html += '      <td>Layout:</td>';
									html += '      <td><select name="newsletter_module[' + module + '][layout_id]">';
									html += '           <option value="99999">All pages</option>';
									{% for layout in layouts %} 
									html += '           <option value="{{ layout['layout_id'] }}">{{ layout['name']|e('html') }}</option>';
									{% endfor %} 
									html += '      </select></td>';
									html += '    </tr>';
									html += '    <tr>';
									html += '      <td>Position:</td>';
									html += '      <td><select name="newsletter_module[' + module + '][position]">';
									html += '       		<option value="menu">Menu</option>';
									html += '				<option value="slideshow">Slideshow</option>';
									html += '				<option value="preface_left">Preface left</option>';
									html += '				<option value="preface_right">Preface right</option>';
									html += '				<option value="preface_fullwidth">Preface fullwidth</option>';
									html += '				<option value="column_left">Column left</option>';
									html += '				<option value="content_big_column">Content big column</option>';
									html += '				<option value="content_top">Content top</option>';
									html += '				<option value="column_right">Column right</option>';
									html += '				<option value="content_bottom">Content bottom</option>';
									html += '				<option value="customfooter_top">CustomFooter Top</option>';
									html += '				<option value="customfooter_bottom">CustomFooter Bottom</option>';
									html += '				<option value="footer_top">Footer top</option>';
									html += '				<option value="footer_left">Footer left</option>';
									html += '				<option value="footer_right">Footer right</option>';
									html += '				<option value="footer_bottom">Footer bottom</option>';
									html += '				<option value="bottom">Bottom</option>';
									html += '      </select></td>';
									html += '    </tr>';
									html += '    <tr>';
									html += '      <td>Status:</td>';
									html += '      <td><select name="newsletter_module[' + module + '][status]">';
									html += '        <option value="1">Enabled</option>';
									html += '        <option value="0">Disabled</option>';
									html += '      </select></td>';
									html += '    </tr>';
									html += '    <tr>';
									html += '      <td>Sort Order:</td>';
									html += '      <td><input type="text" name="newsletter_module[' + module + '][sort_order]" value="" size="3" /></td>';
									html += '    </tr>';
									html += '  </table>'; 
									html += '</div>';
										
									$('#newsletter_modules > img').before('<a href="#newsletter_module_' + module + '" id="element_' + module + '">' + module + ' &nbsp;<img src="view/image/module_template/delete-slider.png" alt="" onclick="$(\'#element_' + module + '\').remove(); $(\'#newsletter_modules a:first\').trigger(\'click\'); $(\'#newsletter_module_' + module + '\').remove(); return false;" /></a>');
									
									$('#newsletter_modules a').tabs();	
									
									$('#newsletter_modules_add').before(html);
									$('#element_' + module).trigger('click');
									
									$('#language_' + module + ' a').tabs();
									
									module++;
								}
							</script>
							
							<script type="text/javascript"> 
								$('#newsletter_modules a').tabs();	
							</script>
						</div>
					</div>
					
					<div>
						<!-- Buttons -->
						<div class="buttons"><input type="submit" name="button-save" class="button-save" value=""></div>
					</div>
				</div>
			</div>		
		</form>
	</div>
</div>
{{ footer }}