{{ header }}{{ column_left }}
<div id="content">
	<div class="page-header">
		<div class="container-fluid">
			<div class="pull-right">
				<button type="submit" form="form" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
				<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a>
			</div>
			<h1>{{ heading_title }}</h1>
			<ul class="breadcrumb">
				{% for breadcrumb in breadcrumbs %}
				<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
				{% endfor %}
			</ul>
		</div>
	</div>
	<div class="container-fluid">
		{% if error_warning %}
		<script>
			usNotify('warning', '{{ error_warning }}');
		</script>
		{% endif %}
		{% if success %}
	    <script>
			usNotify('success', '{{ success }}');
		</script>
	    {% endif %}
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
			</div>
			<div class="panel-body">
				<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form" class="form-horizontal">
					<ul class="nav nav-tabs">
						<li class="active"><a href="#setting-tab" data-toggle="tab">{{ tab_setting }}</a></li>
						<li><a href="#list-tab" data-toggle="tab">{{ tab_list }}</a></li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="setting-tab">
							<div class="form-group">
								<label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
								<div class="col-sm-10">
									<div class="toggle-group">
										<input type="checkbox" name="oct_popup_found_cheaper_status" {% if oct_popup_found_cheaper_status %}checked="checked"{% endif %} id="oct_popup_found_cheaper_status" tabindex="1">
										<label for="oct_popup_found_cheaper_status"></label>
										<div class="onoffswitch pull-left" aria-hidden="true">
											<div class="onoffswitch-label">
												<div class="onoffswitch-inner"></div>
												<div class="onoffswitch-switch"></div>
											</div>
										</div>
									</div>
								</div>
		                    </div>
		                    <div id="all_settings" {% if (oct_popup_found_cheaper_status is not defined or (oct_popup_found_cheaper_status is defined and not oct_popup_found_cheaper_status)) %}style="display:none"{% endif %}>
								<div class="form-group">
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-notify_status">{{ entry_notify_status }}</label>
										<div class="col-sm-8">
											<div class="toggle-group">
												<input type="checkbox" name="oct_popup_found_cheaper_data[notify_status]" {% if oct_popup_found_cheaper_data.notify_status %}checked="checked"{% endif %} id="notify_status" tabindex="1">
												<label for="notify_status"></label>
												<div class="onoffswitch pull-left" aria-hidden="true">
													<div class="onoffswitch-label">
														<div class="onoffswitch-inner"></div>
														<div class="onoffswitch-switch"></div>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-notify_email"><span data-toggle="tooltip" data-container="#setting-tab" title="{{ help_email }}">{{ entry_notify_email }}</span></label>
										<div class="col-sm-8">
											<input type="text" name="oct_popup_found_cheaper_data[notify_email]" value="{{ oct_popup_found_cheaper_data['notify_email'] }}" id="input-notify_email" class="form-control" />
											{% if error_notify_email %}
											<div class="text-danger">
												<script>
													usNotify('warning', '{{ error_notify_email }}');
												</script>
											</div>
											{% endif %}
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-name">{{ entry_name }}</label>
										<div class="col-sm-8">
											<select name="oct_popup_found_cheaper_data[name]" id="input-name" class="form-control">
												{% if oct_popup_found_cheaper_data.name == 1 %}
												<option value="1" selected="selected">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% elseif oct_popup_found_cheaper_data.name == 2 %} 
												<option value="1">{{ text_enabled }}</option>
												<option value="2" selected="selected">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% else %}
												<option value="1">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0" selected="selected">{{ text_disabled }}</option>
												{% endif %}
											</select>
										</div>
									</div>
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-email">{{ entry_email }}</label>
										<div class="col-sm-8">
											<select name="oct_popup_found_cheaper_data[email]" id="input-email" class="form-control">
												{% if oct_popup_found_cheaper_data.email is defined and oct_popup_found_cheaper_data.email == 1 %}
												<option value="1" selected="selected">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% elseif oct_popup_found_cheaper_data.email is defined and oct_popup_found_cheaper_data.email == 2 %}
												<option value="1">{{ text_enabled }}</option>
												<option value="2" selected="selected">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% else %}
												<option value="1">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0" selected="selected">{{ text_disabled }}</option>
												{% endif %}
											</select>
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-telephone">{{ entry_telephone }}</label>
										<div class="col-sm-8">
											<select name="oct_popup_found_cheaper_data[telephone]" id="input-telephone" class="form-control">
												{% if oct_popup_found_cheaper_data.telephone == 1 %}
												<option value="1" selected="selected">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% elseif oct_popup_found_cheaper_data.telephone == 2 %} 
												<option value="1">{{ text_enabled }}</option>
												<option value="2" selected="selected">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% else %}
												<option value="1">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0" selected="selected">{{ text_disabled }}</option>
												{% endif %}
											</select>
										</div>
									</div>
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-mask">{{ entry_mask }}</label>
										<div class="col-sm-8">
											<input type="text" name="oct_popup_found_cheaper_data[mask]" value="{{ oct_popup_found_cheaper_data['mask'] }}" placeholder="{{ entry_mask_info }}" id="input-mask" class="form-control" />
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-link">{{ entry_link }}</label>
										<div class="col-sm-8">
											<select name="oct_popup_found_cheaper_data[link]" id="input-link" class="form-control">
												{% if oct_popup_found_cheaper_data.link == 1 %}
												<option value="1" selected="selected">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% elseif oct_popup_found_cheaper_data.link == 2 %} 
												<option value="1">{{ text_enabled }}</option>
												<option value="2" selected="selected">{{ text_enabled_required }}</option>
												<option value="0">{{ text_disabled }}</option>
												{% else %}
												<option value="1">{{ text_enabled }}</option>
												<option value="2">{{ text_enabled_required }}</option>
												<option value="0" selected="selected">{{ text_disabled }}</option>
												{% endif %}
											</select>
										</div>
									</div>
									<div class="col-sm-6">
										<label class="col-sm-4 control-label" for="input-comment">{{ entry_comment }}</label>
										<div class="col-sm-8">
											<div class="toggle-group">
												<input type="checkbox" name="oct_popup_found_cheaper_data[comment]" {% if oct_popup_found_cheaper_data.comment %}checked="checked"{% endif %} id="input-comment" tabindex="1">
												<label for="input-comment"></label>
												<div class="onoffswitch pull-left" aria-hidden="true">
													<div class="onoffswitch-label">
														<div class="onoffswitch-inner"></div>
														<div class="onoffswitch-switch"></div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane" id="list-tab">
							<div id="history"></div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
$('#oct_popup_found_cheaper_status').change(function() {
    var $input = $(this);

    if ($input.is(":checked")) {
        $("#all_settings").slideDown('slow');
    } else {
        $("#all_settings").slideUp('slow');
    }
});

$('#history').delegate('.pagination a', 'click', function(e) {
	e.preventDefault();
	$('#history').load(this.href);
});

$('#history').load('index.php?route=octemplates/module/oct_popup_found_cheaper/history&user_token={{ user_token }}');
	
function delete_selected(request_id) {
	$.ajax({
		type: 'post',
		url:  'index.php?route=octemplates/module/oct_popup_found_cheaper/delete_selected&user_token={{ user_token }}&delete=' + request_id,
		dataType: 'json',
		cache: false,
		success: function(json) {
			$('#history').load('index.php?route=octemplates/module/oct_popup_found_cheaper/history&user_token={{ user_token }}');
		}
	});
}

function delete_all() {
	$.ajax({
		type: 'get',
		url:  'index.php?route=octemplates/module/oct_popup_found_cheaper/delete_all&user_token={{ user_token }}',
		dataType: 'json',
		cache: false,
		success: function(json) {
			$('#history').load('index.php?route=octemplates/module/oct_popup_found_cheaper/history&user_token={{ user_token }}');
		}
	});
}

function delete_all_selected() {
	$.ajax({
		type: 'post',
		cache: false,
		url:  'index.php?route=octemplates/module/oct_popup_found_cheaper/delete_all_selected&user_token={{ user_token }}',
		data: $('#history input[type=\'checkbox\']:checked'),
		dataType: 'json',
		success: function(json) {
			$('#history').load('index.php?route=octemplates/module/oct_popup_found_cheaper/history&user_token={{ user_token }}');
		}
	});
}
</script>
{{ footer }}