  {{ header }}
  <div class="bg-white">
  <div class="breadcrumb-container">
    <div class="container">
    <div class="row">
    <div class="col-sm-12 col-md-5 col-lg-4">
        <h3 class="home-title">Register</h3>
      </div>
      </div>
      </div>
  </div>
<div id="account-register" class="container">
  <div class="row row-responsive">
    {{ column_left }}
    <div id="content" class="col">{{ content_top }}
      {# <h2>{{ heading_title }}</h2> #}
      
      <form id="form-register" action="{{ register }}" method="post" data-oc-toggle="ajax">
        <fieldset id="account">


  <div class="row">
    <div class="col-sm-6"></div>
    <div class="col-sm-6"></div>
    <div class="col-sm-6"></div>
    <div class="col-sm-6"></div>
    <div class="col-sm-6"></div>
    <div class="col-sm-6"></div>
  </div>

          <legend>{{ text_your_details }}</legend>
          <div class="row">
            {% if customer_groups|length > 1 %}
          
            <label class="col-sm-2 col-form-label">Personal info</label>
            <div class="col-sm-6 mb-3 required">
              <select name="customer_group_id" id="input-customer-group" class="form-select">
                {% for customer_group in customer_groups %}
                  <option value="{{ customer_group.customer_group_id }}"{% if customer_group.customer_group_id == customer_group_id %} selected{% endif %}>{{ customer_group.name }}</option>
                {% endfor %}
              </select>
            </div>
          {% endif %}
            <div class="col-sm-6 form-floating mb-3 required">
              <input type="text" name="firstname" value="" placeholder="{{ entry_firstname }}" id="input-firstname" class="form-control"/>
              <label for="input-firstname" class="col-sm-2 col-form-label">{{ entry_firstname }}</label>
              <div id="error-firstname" class="invalid-feedback"></div>
            </div>

            <div class="col-sm-6 form-floating mb-3 required">
              <input type="text" name="lastname" value="" placeholder="{{ entry_lastname }}" id="input-lastname" class="form-control"/>
              <label for="input-lastname" class="col-sm-2 col-form-label">{{ entry_lastname }}</label>
              <div id="error-lastname" class="invalid-feedback"></div>
            </div>


            <div class="col-sm-6 mb-3 required form-floating">
              <input type="email" name="email" value="" placeholder="{{ entry_email }}" id="input-email" class="form-control"/>
              <label for="input-email" class="col-sm-2 col-form-label">{{ entry_email }}</label>
              <div id="error-email" class="invalid-feedback"></div>
            </div>

              <div class="col-sm-6 form-floating required mb-3">
                <input type="tel" name="telephone" value="" placeholder="{{ entry_telephone }}" id="input-telephone" class="form-control"/>
                <label for="input-telephone" class="col-sm-2 col-form-label">{{ entry_telephone }}</label>
                <div id="error-telephone" class="invalid-feedback"></div>
              </div>

              <div class="col-sm-6 form-floating mb-3">
                <input type="password" name="password" value="" placeholder="{{ entry_password }}" id="input-password" class="form-control"/>
                <label for="input-password" class="col-sm-2 col-form-label">{{ entry_password }}</label>
                <div id="error-password" class="invalid-feedback"></div>
              </div>

              <div class="col-sm-6 form-floating mb-3">
                <input type="password" name="password" value="" placeholder="Confirm password" id="confirm-password" class="form-control"/>
                <label for="input-password" class="col-sm-2 col-form-label">Confirm password</label>
                <div id="error-con-password" class="invalid-feedback"></div>
              </div>

            </div>

          {% for custom_field in custom_fields %}

            {% if custom_field.type == 'select' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <select name="custom_field[{{ custom_field.custom_field_id }}]" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-select">
                    <option value="">{{ text_select }}</option>
                    {% for custom_field_value in custom_field.custom_field_value %}
                      <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
                    {% endfor %}
                  </select>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'radio' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div id="input-custom-field-{{ custom_field.custom_field_id }}">
                    {% for custom_field_value in custom_field.custom_field_value %}
                      <div class="form-check">
                        <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" id="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/> <label for="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-label">{{ custom_field_value.name }}</label>
                      </div>
                    {% endfor %}
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'checkbox' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div id="input-custom-field-{{ custom_field.custom_field_id }}">
                    {% for custom_field_value in custom_field.custom_field_value %}
                      <div class="form-check">
                        <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" id="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/> <label for="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-label">{{ custom_field_value.name }}</label>
                      </div>
                    {% endfor %}
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'text' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control"/>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'textarea' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <textarea name="custom_field[{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control">{{ custom_field.value }}</textarea>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'file' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div>
                    <button type="button" data-oc-toggle="upload" data-oc-url="{{ upload }}" data-oc-size-max="{{ config_file_max_size }}" data-oc-size-error="{{ error_upload_size }}" data-oc-target="#input-custom-field-{{ custom_field.custom_field_id }}" class="custom-btn btn btn-light"><i class="fa-solid fa-upload"></i> {{ button_upload }}</button>
                    <input type="hidden" name="custom_field[{{ custom_field.custom_field_id }}]" value="" id="input-custom-field-{{ custom_field.custom_field_id }}"/>
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'date' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div class="input-group">
                    <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control date"/>
                    <div class="input-group-text"><i class="fa-regular fa-calendar"></i></div>
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'time' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div class="input-group">
                    <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control time"/>
                    <div class="input-group-text"><i class="fa-regular fa-calendar"></i></div>
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

            {% if custom_field.type == 'datetime' %}
              <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
                <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                <div class="col-sm-12">
                  <div class="input-group">
                    <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control datetime"/>
                    <div class="input-group-text"><i class="fa-regular fa-calendar"></i></div>
                  </div>
                  <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
                </div>
              </div>
            {% endif %}

          {% endfor %}
        </fieldset>

        <fieldset>
          <legend>Company info</legend>
          <div class="row">
            <div class="col-sm-12 form-floating required mb-3">
                <input type="tel" name="telephone" value="" placeholder="Company Name *" id="input-company" class="form-control"/>
                <label for="input-company" class="col-sm-2 col-form-label">Company Name *</label>
                <div id="error-company" class="invalid-feedback"></div>
              </div>
              <div class="col-sm-6 form-floating required mb-3">
                <input type="file" name="upload license" value="" placeholder="Upload the Trade license  *" class="form-control"/>
              </div>
              <div class="col-sm-6 form-floating mb-3">
                <input type="file" name="upload certificate" value="" placeholder="Upload the VAT Certificate " class="form-control"/>
              </div>
          </div>
        </fieldset>
       
        {{ captcha }}

        <div class="d-inline-block pt-2 pd-2 w-100 mb-3">
          <div class="">
            {% if text_agree %}
              <div class="form-check form-check-inline w-100">
                <label class="form-check-label" style="font-size: 13px;">{{ text_agree }}</label>
                <input type="checkbox" name="agree" value="1" style="height: 12px; width: 12px;" class="form-check-input"/>
              </div>
            {% endif %}
            <div class="my-3">
            <button type="submit" class="custom-btn btn btn-primary">Register</button>
            </div>
            <p class="already-have">{{ text_account_already }}</p>
          </div>
        </div>
      </form>
      {{ content_bottom }}
    </div>
    {{ column_right }}
  </div>
</div>
</div>
<script type="text/javascript"><!--
$('#input-customer-group').on('change', function () {
    $.ajax({
        url: 'index.php?route=account/custom_field&customer_group_id=' + this.value + '&language={{ language }}',
        dataType: 'json',
        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) {
            console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    });
});

$('#input-customer-group').trigger('change');
//--></script>
{{ footer }}
