<div class="panel panel-danger">
  <div class="panel-heading">
    <span class="panel-title">Ustawienia sellasist.com</span>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-lg-6">
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">Sellasist API</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="api_code" name="api_code" placeholder="" value="<?= $this -> settings['api_code'];?>">
                <span class="input-group-addon cursor" field-id="api_code">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group mb10">
          <label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację z sellasist.com</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 mb10">
          <label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację produktów</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <select class="form-control" id="sync_products" name="sync_products">
                  <option value="">--- wybierz ---</option>
                  <option value="0" <? if ( !$this -> settings['sync_products'] ):?>selected<? endif;?>>nie</option>
                  <option value="1" <? if ( $this -> settings['sync_products'] ):?>selected<? endif;?>>tak</option>
                </select>
                <span class="input-group-addon cursor" field-id="sync_products">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group mb10">
          <label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację zamówień</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <select class="form-control" id="sync_orders" name="sync_orders">
                  <option value="">--- wybierz ---</option>
                  <option value="0" <? if ( !$this -> settings['sync_orders'] ):?>selected<? endif;?>>nie</option>
                  <option value="1" <? if ( $this -> settings['sync_orders'] ):?>selected<? endif;?>>tak</option>
                </select>
                <span class="input-group-addon cursor" field-id="sync_orders">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-lg-3 control-label" for="inputDefault">Data rozpoczęcia synchronizacji zamówień</label>
          <div class="col-lg-9">
            <div class="bs-component">
              <div class="input-group">
                <input class="form-control" type="text" id="sync_orders_date_start" name="sync_orders_date_start" placeholder="" value="<?= $this -> settings['sync_orders_date_start'];?>">
                <span class="input-group-addon cursor" field-id="sync_orders_date_start">
                  <i class="fa fa-save"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-lg-6">
          <a href="/admin/integrations/get_sellasist_status_types_list/" class="btn btn-primary btn-block">Pobierz statusy zamówień</a>
          <a href="/admin/integrations/get_sellasist_payment_types_list/" class="btn btn-primary btn-block">Pobierz metody płatności</a>
          <a href="/admin/integrations/get_sellasist_shipments_list/" class="btn btn-primary btn-block">Pobierz metody dostawy</a>
      </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/sellasist_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>