<div class="panel panel-danger">
  <div class="panel-heading">
    <span class="panel-title">Ustawienia shopPRO</span>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-lg-6">
        <div class="form-group mb10">
          <label class="col-lg-3 control-label" for="inputDefault">Włącz integrację z innym sklepem ShopPRO</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <select class="form-control" id="enabled" name="enabled">
                  <option value="">--- wybierz ---</option>
                  <option value="0" <? if ( !$this -> settings['enabled'] ):?>selected<? endif;?>>nie</option>
                  <option value="1" <? if ( $this -> settings['enabled'] ):?>selected<? endif;?>>tak</option>
                </select>
                <span class="input-group-addon cursor" field-id="enabled">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">DB host</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="db_host" name="db_host" placeholder="" value="<?= $this -> settings['db_host'];?>">
                <span class="input-group-addon cursor" field-id="db_host">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <!-- DB użytkownik -->
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">DB użytkownik</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="db_user" name="db_user" placeholder="" value="<?= $this -> settings['db_user'];?>">
                <span class="input-group-addon cursor" field-id="db_user">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <!-- DB hasło -->
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">DB hasło</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="db_password" name="db_password" placeholder="" value="<?= $this -> settings['db_password'];?>">
                <span class="input-group-addon cursor" field-id="db_password">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <!-- DB nazwa bazy -->
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">DB nazwa</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="db_name" name="db_name" placeholder="" value="<?= $this -> settings['db_name'];?>">
                <span class="input-group-addon cursor" field-id="db_name">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <!-- domena -->
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">domena</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="domain" name="domain" placeholder="" value="<?= $this -> settings['domain'];?>">
                <span class="input-group-addon cursor" field-id="domain">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-lg-6">

      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  $(function() {
    $('body').on('click', '.input-group-addon', function() {
      var field_id = $(this).attr('field-id');
      var value = $('#' + field_id).val();
      $.ajax({
        url: '/admin/integrations/shoppro_settings_save/',
        type: 'POST',
        data: {
          field_id: field_id,
          value: value
        },
        success: function(response) {
          response = JSON.parse(response);
          if (response.status == 'ok') {
            $('#' + field_id).val(response.value);
            $('#' + field_id).closest('.form-group').addClass('has-success');
            setTimeout(function() {
              $('#' + field_id).closest('.form-group').removeClass('has-success');
            }, 5000);
          }
        }
      });
    })
  });
</script>