{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-tracking-input" 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 %}
    <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>
    {% 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-tracking-input" class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="tracking_input_status" id="input-status" class="form-control">
                {% if tracking_input_status %}
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
                {% else %}
                <option value="1">{{ text_enabled }}</option>
                <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
            </div>
          </div>		
		{% if accc %}
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-choose-code"><span data-toggle="tooltip" title="{{ help_choose_code_account }}">{{ entry_choose_code_account }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_choose_code" id="input-choose-code" class="form-control">
                {% if tracking_input_choose_code %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>		
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-choose-code-checkout"><span data-toggle="tooltip" title="{{ help_choose_code_checkout }}">{{ entry_choose_code_checkout }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_choose_code_checkout" id="input-choose-code-checkout" class="form-control">
                {% if tracking_input_choose_code_checkout %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>				
		{% else %}
          <div class="form-group">
			<input type="hidden" name="tracking_input_choose_code_checkout" value="{{ tracking_input_choose_code_checkout }}" />
            <label class="col-sm-2 control-label" for="input-choose-code"><span data-toggle="tooltip" title="{{ help_choose_code }}">{{ entry_choose_code }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_choose_code" id="input-choose-code" class="form-control">
                {% if tracking_input_choose_code %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>		
		{% endif %}
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-require-code"><span data-toggle="tooltip" title="{{ help_choose_code_required }}">{{ entry_choose_code_required }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_require_code" id="input-require-code" class="form-control">
                {% if tracking_input_require_code %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>			
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-edit-code"><span data-toggle="tooltip" title="{{ help_edit_code }}">{{ entry_edit_code }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_edit_code" id="input-edit-code" class="form-control">
                {% if tracking_input_edit_code %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>			
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-show-close-button"><span data-toggle="tooltip" title="{{ help_show_close_button }}">{{ entry_show_close_button }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_show_close_button" id="input-show-close-button" class="form-control">
                {% if tracking_input_show_close_button %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>					  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-no-cookie-only">{{ entry_no_cookie_only }}</label>
            <div class="col-sm-10">
              <select name="tracking_input_no_cookie_only" id="input-no-cookie-only" class="form-control">
                {% if tracking_input_no_cookie_only %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>			  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-show"><span data-toggle="tooltip" title="{{ help_show }}">{{ entry_show }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_show" id="input-show" class="form-control">
					{% if tracking_input_show == 'session' %}
					<option value="session" selected="selected">{{ option_session }}</option>
					{% else %}
					<option value="session">{{ option_session }}</option>
					{% endif %}
					{% if tracking_input_show == 'page' %}
					<option value="page" selected="selected">{{ option_page }}</option>
					{% else %}
					<option value="page">{{ option_page }}</option>
					{% endif %}
					{% if tracking_input_show == 'once' %}
					<option value="once" selected="selected">{{ option_once }}</option>
					{% else %}
					<option value="once">{{ option_once }}</option>
					{% endif %}
              </select>
            </div>
          </div>			  		  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-redirect"><span data-toggle="tooltip" title="{{ help_redirect }}">{{ entry_redirect }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_redirect" id="input-redirect" class="form-control">
                {% if tracking_input_redirect %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>			  		  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-allow-coupon"><span data-toggle="tooltip" title="{{ help_allow_coupon }}">{{ entry_allow_coupon }}</span></label>
            <div class="col-sm-10">
              <select name="tracking_input_allow_coupon" id="input-allow-coupon" class="form-control">
                {% if tracking_input_allow_coupon %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>		
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-allow-marketing">{{ entry_allow_marketing }}</label>
            <div class="col-sm-10">
              <select name="tracking_input_allow_marketing" id="input-allow-marketing" class="form-control">
                {% if tracking_input_allow_marketing %}
                <option value="1" selected="selected">{{ text_yes }}</option>
                <option value="0">{{ text_no }}</option>
                {% else %}
                <option value="1">{{ text_yes }}</option>
                <option value="0" selected="selected">{{ text_no }}</option>
                {% endif %}
              </select>
            </div>
          </div>				  
		<h2>{{ heading_add_module }}</h2>
		<div class="container-fluid text-info"><a href="javascript:;" onclick="javascript:$(this).parent().find('.help').toggle();">{{ text_show_help }}</a><br /><span class="help" style="display:none;">{{ text_explanation }}</span></div>  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-name">{{ entry_name }}</label>
            <div class="col-sm-10">
              <input type="text" name="tracking_input_module[name]" value="" placeholder="{{ entry_name }}" id="input-module-name" class="form-control" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-language">{{ entry_language }}</label>
            <div class="col-sm-10">
				<select name="tracking_input_module[language_id]" class="form-control" id="input-module-language">
				 {% for language in languages %}
					<option value="{{ language['language_id'] }}">{{ language['name'] }}</option>
                  {% endfor %}
                </select>
            </div>
          </div>		  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-text">{{ entry_text }}</label>
            <div class="col-sm-10">				
              <textarea name="tracking_input_module[text]" placeholder="{{ entry_text }}" id="input-module-text" class="form-control"></textarea>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-text-heading">{{ entry_text_heading }}</label>
            <div class="col-sm-10">
              <input type="text" name="tracking_input_module[text_heading]" value="" placeholder="{{ entry_text_heading }}" id="input-module-text-heading" class="form-control" />
            </div>
          </div>		  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-text-thankyou">{{ entry_text_thankyou }}</label>
            <div class="col-sm-10">
              <input type="text" name="tracking_input_module[text_thankyou]" value="" placeholder="{{ entry_text_thankyou }}" id="input-module-text-thankyou" class="form-control" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-button">{{ entry_button }}</label>
            <div class="col-sm-10">
              <input type="text" name="tracking_input_module[button]" value="" placeholder="{{ entry_button }}" id="input-module-button" class="form-control" />
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-error-message">{{ entry_error_message }}</label>
            <div class="col-sm-10">
              <input type="text" name="tracking_input_module[error_message]" value="" placeholder="{{ entry_error_message }}" id="input-module-error-message" class="form-control" />
            </div>
          </div>		  
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-template">{{ entry_head_template }}</label>
            <div class="col-sm-10">
				<select name="tracking_input_module[template]" class="form-control" id="input-module-template">				 
				 {% for tpl in templates %}
					<option value="{{ tpl }}">{{ templates_display[tpl]['title'] }}</option>
                  {% endfor %}
                </select>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-module-status">{{ entry_module_status }}</label>
            <div class="col-sm-10">
              <select name="tracking_input_module[status]" id="input-module-status" class="form-control">
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
              </select>
            </div>
          </div>			  
        </form>
		<h3>{{ heading_templates }}</h3>
		<div class="form-group">			
			<div class="col-sm-4">
				<table class="table table-striped">
					{% for tpl_display in templates_display %}
					<tr>
						<td><b>{{ tpl_display['title'] }}</b></td>
						<td>{% if tpl_display['used'] %}
								{{ warning_used_template }}
						{% elseif tpl_display['tpl'] == 'default_row' or tpl_display['tpl'] == 'default_column' %}
								{{ warning_default_template }}
							{% else %}
						[ <a href="javascript:;" class="delete_tpl" rel="{{ tpl_display['tpl'] }}">{{ button_delete }}</a> ]
						{% endif %}<br />
						[ <a href="javascript:;" class="new_tpl" rel="{{ tpl_display['tpl'] }}">{{ text_copy_to_new }}</a> ]
						<div id="new_tpl_{{ tpl_display['tpl'] }}" style="display:none;">
						<input type="text" id="new_tpl_name_{{ tpl_display['tpl'] }}" /><br />
						<span class="help">{{ text_tpl_name_req }}</span><br />
						<input type="button" value="{{ text_copy_to_new }}" id="new_tpl_save_{{ tpl_display['tpl'] }}" class="new_tpl_save" rel="{{ tpl_display['tpl'] }}" />
						</div>
						<div style="padding-top:10px;padding-left:6px">
						<small>{{ tpl_display['text_edit'] }}</small></div>
						</td>
					</tr>
					{% endfor %}
				</table>
			</div>				
		</div>
      </div>
    </div>
  </div>
<script type="text/javascript"><!--

$('.new_tpl').click(function() {
	$('#new_tpl_'+$(this).attr('rel')).show();
});

$('.new_tpl_save').click(function() {
	var _tpl = $(this).attr('rel');
	var _n = $('#new_tpl_name_'+_tpl);
	if(/[^a-zA-Z0-9 ]+/.test(_n.val())) {
		$(this).parent().find('.help').attr('style', 'font-weight:bold;color:#f00;');
		return;
	}
	_n.val(_n.val().toLowerCase());
	$.get(document.location.href.replace('module/tracking_input', 'module/tracking_input/tpl_create&tpl='+$(this).attr('rel')+'&name='+_n.val().replace(/\s+/g, '_')), function(_r) {
		if(_r == '1') {
			document.location.reload();
		} else {
			alert((_r == '0' ? '{{ error_create_tpl }}' : _r));
		}
	})	
});

$('.delete_tpl').click(function() {
	if(!confirm('{{ warning_delete_template }}')) return;
	var _this = this;
	$.get(document.location.href.replace('module/tracking_input', 'module/tracking_input/tpl_delete&tpl='+$(this).attr('rel')), function(_r) {
		if(_r =='1') {
			$(_this).parent().parent().remove();
			document.location.reload();
		} else {
			alert((_r == '0' ? '{{ error_delete_tpl }}' : _r));
		}
	})
});

//--></script></div>
{{ footer }}