{{ header }}
<div id="affiliate-register" class="container">
	{{ oct_breadcrumbs }}
	<div class="row">
		<div class="col-lg-12">
			<h1 class="rm-page-title">{{ heading_title }}</h1>
		</div>
	</div>
	<div class="content-top-box">{{ content_top }}</div>
	{% if error_warning %}
	<script>
	rmNotify('warning', '{{ error_warning }}');
	</script>
	{% endif %}
	<div class="row">
	    <div id="content" class="col-12">
			<div class="rm-content rm-account-content h-100">
		      <div class="rm-account-text mb-4">{{ text_account_already }}</div>
		      <div class="rm-account-text mb-4">{{ text_signup }}</div>
		      <form action="{{ action }}" method="post" enctype="multipart/form-data" class="form-horizontal">
		        <fieldset id="account" class="rm-account-form">
		          <legend class="rm-content-title">{{ text_your_details }}</legend>
		          <div class="form-group d-{% if customer_groups|length > 1 %}block {% else %}none {% endif %}">
		            <label class="rm-control-label"><span class="required">*</span> {{ entry_customer_group }}</label>
		            {% for customer_group in customer_groups %}
		            {% if customer_group.customer_group_id == customer_group_id %}
		            <div class="radio">
		                <label class="option">
			                <input type="radio" name="customer_group_id" class="input-radio" value="{{ customer_group.customer_group_id }}" checked="checked" />
							<span class="radio-box"></span>
			                {{ customer_group.name }}
		                </label>
		            </div>
		            {% else %}
		            <div class="radio">
		                <label class="option">
			                <input type="radio" name="customer_group_id" class="input-radio" value="{{ customer_group.customer_group_id }}" />
							<span class="radio-box"></span>
			                {{ customer_group.name }}
		                </label>
		            </div>
		            {% endif %}
		            {% endfor %}
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-firstname"><span class="required">*</span> {{ entry_firstname }}</label>
		            {% if error_firstname %}
		            <script>
					rmNotify('warning', '{{ error_firstname }}');
					</script>
		            {% endif %}
		            <input type="text" name="firstname" value="{{ firstname }}" placeholder="{{ entry_firstname }}" id="input-firstname" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-lastname"><span class="required">*</span> {{ entry_lastname }}</label>
		            {% if error_lastname %}
		            <script>
					rmNotify('warning', '{{ error_lastname }}');
					</script>
		            {% endif %}
		            <input type="text" name="lastname" value="{{ lastname }}" placeholder="{{ entry_lastname }}" id="input-lastname" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-email"><span class="required">*</span> {{ entry_email }}</label>
		            {% if error_email %}
		            <script>
					rmNotify('warning', '{{ error_email }}');
					</script>
		            {% endif %}
		            <input type="text" name="email" value="{{ email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-telephone"><span class="required">*</span> {{ entry_telephone }}</label>
		            {% if error_telephone %}
		            <script>
					rmNotify('warning', '{{ error_telephone }}');
					</script>
		            {% endif %}
		            <input type="text" name="telephone" value="{{ telephone }}" placeholder="{{ entry_telephone }}" id="input-telephone" class="form-control" />
		          </div>
		          {% for custom_field in custom_fields %}
		          {% if custom_field.location == 'account' %}
		          {% if custom_field.type == 'select' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('warning', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="rm-select form-control">
		                <option value="">{{ text_select }}</option>
						{% for custom_field_value in custom_field.custom_field_value %}
		                {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
		                <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option>
		                {% else %}
		                <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
		                {% endif %}
		                {% endfor %}
		            </select>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'radio' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div>
		            	{% for custom_field_value in custom_field.custom_field_value %}
		                <div class="radio">
			                {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
			                <label class="option">
			                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" />
			                    <span class="radio-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% else %}
			                <label class="option">
			                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" />
			                    <span class="radio-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% endif %}
		                </div>
		                {% endfor %}
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'checkbox' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="form-checkbox-group">
		            	{% for custom_field_value in custom_field.custom_field_value %}
		                <div class="checkbox">
			                {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in register_custom_field[custom_field.custom_field_id] %}
			                <label>
			                    <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" class="rm-form-checkbox-input" />
			                    <span class="check-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% else %}
			                <label>
			                    <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="rm-form-checkbox-input" />
			                    <span class="check-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% endif %}
		                </div>
		                {% endfor %}
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'text' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'textarea' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}</textarea>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'file' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="rm-btn dark"><i class="fa fa-upload"></i> {{ button_upload }}</button>
		              <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}  {{ register_custom_field[custom_field.custom_field_id] }} {% endif %}" />
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'date' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group date">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-calendar"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'time' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group time">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-clock"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'time' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group datetime">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-calendar"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		          {% endif %}
		          {% endfor %}
		        </fieldset>
		        <fieldset id="affiliate" class="rm-account-form">
		          <legend class="rm-content-title mt-4">{{ text_your_affiliate }}</legend>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-company">{{ entry_company }}</label>
		            <input type="text" name="company" value="{{ company }}" placeholder="{{ entry_company }}" id="input-company" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-website">{{ entry_website }}</label>
		            <input type="text" name="website" value="{{ website }}" placeholder="{{ entry_website }}" id="input-website" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-tax">{{ entry_tax }}</label>
		            <input type="text" name="tax" value="{{ tax }}" placeholder="{{ entry_tax }}" id="input-tax" class="form-control" />
		          </div>
		          <div class="form-checkbox-group">
		            <div class="rm-content-title">{{ entry_payment }}</div>
		            <div class="checkbox">
		            	<label>
			            	{% if payment == 'cheque' %}
			                <input type="radio" id="aff_check" class="rm-form-checkbox-input" name="payment" value="cheque" checked="checked" />
			                {% else %}
			                <input type="radio" id="aff_check" class="rm-form-checkbox-input" name="payment" value="cheque" />
			                {% endif %}
			                <span class="check-box"></span>
			                {{ text_cheque }}
		                </label>
		            </div>
		            <div class="checkbox">
		            	<label>
			            	{% if payment == 'paypal' %}
			                <input type="radio" id="aff_paypal" class="rm-form-checkbox-input" name="payment" value="paypal" checked="checked" />
			                {% else %}
			                <input type="radio" id="aff_paypal" class="rm-form-checkbox-input" name="payment" value="paypal" />
			                {% endif %}
			                <span class="check-box"></span>
			                {{ text_paypal }}
		                </label>
		            </div>
		            <div class="checkbox">
		            	<label>
			            	{% if payment == 'bank' %}
			                <input type="radio" id="aff_bank" class="rm-form-checkbox-input" name="payment" value="bank" checked="checked" />
			                {% else %}
			                <input type="radio" id="aff_bank" class="rm-form-checkbox-input" name="payment" value="bank" />
			                {% endif %}
			                <span class="check-box"></span>
			                {{ text_bank }}
		                </label>
		            </div>
		          </div>
		          <div class="form-group payment" id="payment-cheque">
		            <label class="rm-control-label" for="input-cheque"><span class="required">*</span> {{ entry_cheque }}</label>
		            {% if error_cheque %}
		            <script>
					rmNotify('warning', '{{ error_cheque }}');
					</script>
		            {% endif %}
		            <input type="text" name="cheque" value="{{ cheque }}" placeholder="{{ entry_cheque }}" id="input-cheque" class="form-control" />
		          </div>
		          <div class="form-group payment" id="payment-paypal">
		            <label class="rm-control-label" for="input-paypal"><span class="required">*</span> {{ entry_paypal }}</label>
		            {% if error_paypal %}
		            <script>
					rmNotify('warning', '{{ error_paypal }}');
					</script>
		            {% endif %}
		            <input type="text" name="paypal" value="{{ paypal }}" placeholder="{{ entry_paypal }}" id="input-paypal" class="form-control" />
		          </div>
		          <div class="payment" id="payment-bank">
		            <div class="form-group">
		              <label class="rm-control-label" for="input-bank-name">{{ entry_bank_name }}</label>
		              <input type="text" name="bank_name" value="{{ bank_name }}" placeholder="{{ entry_bank_name }}" id="input-bank-name" class="form-control" />
		            </div>
		            <div class="form-group">
		              <label class="rm-control-label" for="input-bank-branch-number">{{ entry_bank_branch_number }}</label>
		              <input type="text" name="bank_branch_number" value="{{ bank_branch_number }}" placeholder="{{ entry_bank_branch_number }}" id="input-bank-branch-number" class="form-control" />
		            </div>
		            <div class="form-group">
		              <label class="rm-control-label" for="input-bank-swift-code">{{ entry_bank_swift_code }}</label>
		              <input type="text" name="bank_swift_code" value="{{ bank_swift_code }}" placeholder="{{ entry_bank_swift_code }}" id="input-bank-swift-code" class="form-control" />
		            </div>
		            <div class="form-group">
		              <label class="rm-control-label" for="input-bank-account-name"><span class="required">*</span> {{ entry_bank_account_name }}</label>
		              {% if error_bank_account_name %}
		            <script>
					rmNotify('warning', '{{ error_bank_account_name }}');
					</script>
		              {% endif %}
		              <input type="text" name="bank_account_name" value="{{ bank_account_name }}" placeholder="{{ entry_bank_account_name }}" id="input-bank-account-name" class="form-control" />
		            </div>
		            <div class="form-group">
		              <label class="rm-control-label" for="input-bank-account-number"><span class="required">*</span> {{ entry_bank_account_number }}</label>
		              {% if error_bank_account_number %}
		            <script>
					rmNotify('warning', '{{ error_bank_account_number }}');
					</script>
		              {% endif %}
		              <input type="text" name="bank_account_number" value="{{ bank_account_number }}" placeholder="{{ entry_bank_account_number }}" id="input-bank-account-number" class="form-control" />
		            </div>
		            {% for custom_field in custom_fields %}
		            {% if custom_field.location == 'affiliate' %}
		            {% if custom_field.type == 'select' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="rm-select form-control">
		                <option value="">{{ text_select }}</option>
		                {% for custom_field_value in custom_field.custom_field_value %}
		                {% if register_custom_field[custom_field.location][custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
		                <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option>
		                {% else %}
		                <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
		                {% endif %}
		                {% endfor %}
		            </select>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'radio' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div>
		            	{% for custom_field_value in custom_field.custom_field_value %}
		                <div class="radio">
			                {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
			                <label class="option">
			                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" />
			                    <span class="radio-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% else %}
			                <label class="option">
			                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" />
			                    <span class="radio-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% endif %}
		                </div>
		                {% endfor %}
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'checkbox' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="form-checkbox-group">
		            	{% for custom_field_value in custom_field.custom_field_value %}
		                <div class="checkbox">
			                {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in register_custom_field[custom_field.custom_field_id] %}
			                <label>
			                    <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" class="rm-form-checkbox-input" />
			                    <span class="check-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% else %}
			                <label>
			                    <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="rm-form-checkbox-input" />
			                    <span class="check-box"></span>
			                    {{ custom_field_value.name }}
			                </label>
			                {% endif %}
		                </div>
		                {% endfor %}
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'text' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'textarea' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}</textarea>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'file' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="rm-btn dark"><i class="fa fa-upload"></i> {{ button_upload }}</button>
		              <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}  {{ register_custom_field[custom_field.custom_field_id] }} {% endif %}" />
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'date' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group date">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-calendar"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'time' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group time">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-clock"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		          {% if custom_field.type == 'time' %}
		          <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
		            <label class="rm-control-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
		            {% if error_custom_field[custom_field.custom_field_id] %}
		            <script>
					rmNotify('danger', '{{ error_custom_field[custom_field.custom_field_id] }}');
					</script>
		            {% endif %}
		            <div class="input-group datetime">
		                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
		                <span class="input-group-btn">
		                	<button type="button" class="rm-btn rm-input-with-btn"><i class="fa fa-calendar"></i></button>
		                </span>
		            </div>
		          </div>
		          {% endif %}
		            {% endif %}
		            {% endfor %}
			      </div>
		        </fieldset>
		        <fieldset class="rm-account-form">
		          <legend class="rm-content-title mt-4">{{ text_your_password }}</legend>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-password"><span class="required">*</span> {{ entry_password }}</label>
		            {% if error_password %}
		            <script>
					rmNotify('warning', '{{ error_password }}');
					</script>
		            {% endif %}
		            <input type="password" name="password" value="{{ password }}" placeholder="{{ entry_password }}" id="input-password" class="form-control" />
		          </div>
		          <div class="form-group">
		            <label class="rm-control-label" for="input-confirm"><span class="required">*</span> {{ entry_confirm }}</label>
		            {% if error_confirm %}
		            <script>
					rmNotify('warning', '{{ error_confirm }}');
					</script>
		            {% endif %}
		            <input type="password" name="confirm" value="{{ confirm }}" placeholder="{{ entry_confirm }}" id="input-confirm" class="form-control" />
		          </div>
		        </fieldset>
		        {{ captcha }}
		        {% if text_agree %}
	        	<div class="form-checkbox-group mt-4">
	        		<label>
			            {% if agree %}
			            <input type="checkbox" name="agree" id="scales" class="rm-form-checkbox-input" value="1" checked="checked" />
			            {% else %}
			            <input type="checkbox" name="agree" id="scales" class="rm-form-checkbox-input" value="1" />
			            {% endif %}
	                    <span class="check-box"></span>
			            {{ text_agree }}
		            </label>
	        	</div>
			    {% endif %}
		        <div class="btn-group mt-2">
		            <input type="submit" value="{{ button_continue }}" class="rm-btn dark" />
		        </div>
		      </form>
		    </div>
	    </div>
	</div>
	{{ content_bottom }}
</div>
<script>
// Sort the custom fields
$('#account .form-group[data-sort]').detach().each(function() {
	if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#account .form-group').length) {
		$('#account .form-group').eq($(this).attr('data-sort')).before(this);
	}

	if ($(this).attr('data-sort') > $('#account .form-group').length) {
		$('#account .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') == $('#account .form-group').length) {
		$('#account .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') < -$('#account .form-group').length) {
		$('#account .form-group:first').before(this);
	}
});

$('#affiliate .form-group[data-sort]').detach().each(function() {
	if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#affiliate .form-group').length) {
		$('#affiliate .form-group').eq($(this).attr('data-sort')).before(this);
	}

	if ($(this).attr('data-sort') > $('#affiliate .form-group').length) {
		$('#affiliate .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') == $('#affiliate .form-group').length) {
		$('#affiliate .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') < -$('#affiliate .form-group').length) {
		$('#affiliate .form-group:first').before(this);
	}
});

$('input[name=\'customer_group_id\']').on('change', function() {
	$.ajax({
		url: 'index.php?route=account/register/customfield&customer_group_id=' + this.value,
		dataType: 'json',
		cache: false,
		success: function(json) {
			$('.custom-field').hide();
			$('.custom-field').removeClass('required');

			for (i = 0; i < json.length; i++) {
				custom_field = json[i];

				$('#custom-field' + custom_field['custom_field_id']).show();

				if (custom_field['required']) {
					$('#custom-field' + custom_field['custom_field_id']).addClass('required');
				}
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

$('input[name=\'customer_group_id\']:checked').trigger('change');

$('button[id^=\'button-custom-field\']').on('click', function() {
	var node = this;

	$('#form-upload').remove();

	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

	$('#form-upload input[name=\'file\']').trigger('click');

	if (typeof timer != 'undefined') {
    	clearInterval(timer);
	}

	timer = setInterval(function() {
		if ($('#form-upload input[name=\'file\']').val() != '') {
			clearInterval(timer);

			$.ajax({
				url: 'index.php?route=tool/upload',
				type: 'post',
				dataType: 'json',
				data: new FormData($('#form-upload')[0]),
				cache: false,
				contentType: false,
				processData: false,
				beforeSend: function() {
					$(node).button('loading');
				},
				complete: function() {
					$(node).button('reset');
				},
				success: function(json) {
					$(node).parent().find('.text-danger').remove();

					if (json['error']) {
						$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
					}

					if (json['success']) {
						alert(json['success']);

						$(node).parent().find('input').val(json['code']);
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		}
	}, 500);
});

$('.date').datetimepicker({
	language: '{{ datepicker }}',
	pickTime: false
});

$('.time').datetimepicker({
	language: '{{ datepicker }}',
	pickDate: false
});

$('.datetime').datetimepicker({
	language: '{{ datepicker }}',
	pickDate: true,
	pickTime: true
});

$('input[name=\'payment\']').on('change', function() {
	$('.payment').hide();

	$('#payment-' + this.value).show();
});

$('input[name=\'payment\']:checked').trigger('change');
</script>
{{ footer }}
