<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
  $(function ()
  {
    $('#settings-tabs').easyResponsiveTabs(
    {
      width: 'auto',
      fit: true,
      tabidentify: 'settings-tabs',
      type: 'vertical'
    });

    $('#additional_info').ckeditor(
            {
              toolbar: 'MyTool',
              height: '150'
            });
  });
</script>
<?
global $db;

ob_start();
?>
<div id="settings-tabs">
  <ul class="resp-tabs-list settings-tabs">
    <li><i class="fa fa-paper-plane"></i>Dane kontaktowe</li>
    <li><i class="fa fa-envelope"></i>Poczta</li>
    <li><i class="fa fa-bars"></i>Dodatkowe ustawienia</li>
    <li><i class="fa fa-code"></i>Kody (m.in. statystyk)</li>
    <li><i class="fa fa-cog"></i>System</li>
    <li><i class="fa fa-refresh"></i>Aktualizacje</li>
  </ul>
  <div class="resp-tabs-container settings-tabs">
    <div>
      <?=
      \Html::input(
              array(
                      'label' => 'Nazwa firmy',
                      'name'  => 'firm_name',
                      'id'    => 'firm_name',
                      'value' => $this -> settings['firm_name']
              )
      );
      ?>
      <?=
      \Html::textarea(
              array(
                      'label' => 'Dodatkowe informacje',
                      'name'  => 'additional_info',
                      'id'    => 'additional_info',
                      'value' => $this -> settings['additional_info']
              )
      );
      ?>
      <?=
      \Html::input_switch(
              array(
                      'label'   => 'Mapa',
                      'name'    => 'google_maps',
                      'checked' => $this -> settings['google_maps'] == 1 ? true : false
              )
      );
      ?>
      <?=
      \Html::textarea(
              array(
                      'label' => 'Mapa - adres',
                      'name'  => 'firm_adress',
                      'id'    => 'firm_adress',
                      'value' => $this -> settings['firm_adress']
              )
      );
      ?>
      <?=
      \Html::input_switch(
              array(
                      'label'   => 'Widget "Telefon"',
                      'name'    => 'widget_phone',
                      'checked' => $this -> settings['widget_phone'] == 1 ? true : false
              )
      );
      ?>
    </div>
    <div>
      <?=
      \Html::input_switch(
              array(
                      'label'   => 'Formularz kontaktowy',
                      'name'    => 'contact_form',
                      'checked' => $this -> settings['contact_form'] == 1 ? true : false
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Email kontaktowy',
                      'name'  => 'contact_email',
                      'id'    => 'contact_email',
                      'value' => $this -> settings['contact_email']
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Email - host',
                      'name'  => 'email_host',
                      'id'    => 'email_host',
                      'value' => $this -> settings['email_host']
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Email - port',
                      'name'  => 'email_port',
                      'id'    => 'email_port',
                      'value' => $this -> settings['email_port']
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Email - login',
                      'name'  => 'email_login',
                      'id'    => 'email_login',
                      'value' => $this -> settings['email_login']
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Email - hasło',
                      'name'  => 'email_password',
                      'id'    => 'email_password',
                      'value' => $this -> settings['email_password'],
                      'type'  => 'text'
              )
      );
      ?>
      <?= \Html::input_switch( [
        'label' => 'Captcha w formularzu kontaktowym',
        'name' => 'contact_form_captcha',
        'checked' => $this -> settings['contact_form_captcha'] == 1 ? true : false
      ] );
      ?>
    </div>
    <div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Ilość aktualności
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Ilość wyświetlanych aktulanośći w boxie [NEWS] ">?</i>
          </div>
        </label>
        <div class="col-lg-9">
          <input class="form-control" type="text" name="news_limit" id="news_limit" value="<?= $this -> settings['news_limit']?>">
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Licznik odwiedzin
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Włączenie licznika odwiedzin na stronie">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="visit_counter" id="visit_counter" <? if ( $this -> settings['visit_counter'] ):?>checked="checked"<? endif;?>>
            <label for="visit_counter"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Kalendarz
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Włączenie kalendarza dla artykułów">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="calendar" id="calendar" <? if ( $this -> settings['calendar'] ):?>checked="checked"<? endif;?>>
            <label for="calendar"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Tagi
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Włączenie tagów dla artykułów">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="tags" id="tags" <? if ( $this -> settings['tags'] ):?>checked="checked"<? endif;?>>
            <label for="tags"></label>
          </div>
        </div>
      </div>
      <?= \Html::input( [
                  'label' => 'Maksmalna wielkość zdjęcia (px)',
                  'name'  => 'image_px',
                  'id'    => 'image_px',
                  'value' => $this -> settings['image_px']
              ] );
      ?>
    </div>
    <div>
      <?=
      \Html::input(
              array(
                      'label' => 'Klucz Google Search Console',
                      'name'  => 'google_search_console',
                      'id'    => 'google_search_console',
                      'value' => $this -> settings['google_search_console']
              )
      );
      ?>
      <?=
      \Html::input(
              array(
                      'label' => 'Facebook link',
                      'name'  => 'facebook_link',
                      'id'    => 'facebook_link',
                      'value' => $this -> settings['facebook_link']
              )
      );
      ?>
      <?=
      \Html::textarea(
              array(
                      'label' => 'Kod statystyk',
                      'name'  => 'statistic_code',
                      'id'    => 'statistic_code',
                      'value' => $this -> settings['statistic_code'],
                      'rows'  => 10
              )
      );
      ?>
      <?=
      \Html::textarea(
              array(
                      'label' => 'Własne reguły htacess',
                      'name'  => 'htaccess',
                      'id'    => 'htaccess',
                      'value' => $this -> settings['htaccess'],
                      'rows'  => 10
              )
      );
      ?>
      <?=
      \Html::textarea(
              array(
                      'label' => 'Własne reguły robots.txt',
                      'name'  => 'robots',
                      'id'    => 'robots',
                      'value' => $this -> settings['robots'],
                      'rows'  => 10
              )
      );
      ?>
    </div>
    <div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Strona konstrukcyjna
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Włączenie strony konstrukcyjnej do tworzenia szablonów">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="devel" id="devel" <? if ( $this -> settings['devel'] ):?>checked="checked"<? endif;?>>
            <label for="devel"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Wersja https://
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Włączenie wersji https:// strony">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="ssl" id="ssl" <? if ( $this -> settings['ssl'] ):?>checked="checked"<? endif;?>>
            <label for="ssl"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">MySQL Debug
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Umożliwienie zapisu zapytań sql do plików">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="mysql_debug" id="mysql_debug" <? if ( $this -> settings['mysql_debug'] ):?>checked="checked"<? endif;?>>
            <label for="mysql_debug"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Htaccess cache
          <div class="popo">
            <i class="popover-btn" data-container="body" data-toggle="popover" data-placement="top" data-content="Aktywny - dla stron rzadko aktualizowanych,<br> Niekatywny - dla stron często aktualizowanych">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="htaccess_cache" id="htaccess_cache" <? if ( $this -> settings['htaccess_cache'] ):?>checked="checked"<? endif;?>>
            <label for="htaccess_cache"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Lazy loading obrazów</label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="lazy_loading" id="lazy_loading" <? if ( $this -> settings['lazy_loading'] ):?>checked="checked"<? endif;?>>
            <label for="lazy_loading"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Generowanie obrazków WEBP</label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="generate_webp" id="generate_webp" <? if ( $this -> settings['generate_webp'] ):?>checked="checked"<? endif;?>>
            <label for="generate_webp"></label>
          </div>
        </div>
      </div>
      <div class="form-group">
        <?= \Html::select( [
                    'label'  => "Struktura linków",
                    'name'   => "links_structure",
                    'values' => [ 0 => 'skrócona', 1 => 'rozwinięta' ],
                    'value'  => $this -> settings['links_structure'] ? 1 : 0
                  ] );?>
      </div>
      <div class="form-group">
        <?= \Html::select( [
                    'label'  => "Wersja strony",
                    'name'   => "link_version",
                    'values' => [ 0 => 'bez www', 1 => 'z www' ],
                    'value'  => $this -> settings['link_version'] ? 1 : 0
                ] );?>
      </div>
      <div class="form-group">
        <?= \Html::select( [
                    'label'  => "Wersja adresów url",
                    'name'   => "url_version",
                    'values' => [ 0 => 'bez / na końcu adresu url', 1 => 'z / na końcu adresu url' ],
                    'value'  => $this -> settings['url_version'] ? 1 : 0
                ] );?>
      </div>
      <div class="form-group">
        <?= \Html::select( [
                    'label'  => "Newsletter",
                    'name'   => "newsletter_cron",
                    'values' => [ 0 => 'wysyłka za pomocą cron i strony', 1 => 'wysyłka za pomocą cron' ],
                    'value'  => $this -> settings['newsletter_cron'] ? 1 : 0
                ] );?>
      </div>
    </div>
    <div>
      <div class="form-group">
        <label class="col-lg-3 control-label">Aktualizacja
          <div class="popo">
            <i class="popover-btn " data-container="body" data-toggle="popover" data-placement="top" data-content="Wyświetlanie informacji o pojawiającej się nowej aktualizacji">?</i>
          </div>
        </label>
        <div class="col-lg-9 pt5">
          <div class="switch switch-primary round switch-inline">
            <input type="checkbox" name="update" id="update" <? if ( $this -> settings['update'] ):?>checked="checked"<? endif;?>>
            <label for="update"></label>
          </div>
        </div>
      </div>
      <?= Html::input(
                array(
                        'label' => 'Numer licencji',
                        'name'  => 'update_key',
                        'id'    => 'update_key',
                        'value' => $this -> settings['update_key']
                )
        );
      ?>
    </div>
    <div class="clear"></div>
    <?
    $out = ob_get_clean();

    $grid                  = new \gridEdit;
    $grid -> id              = 'settings-edit';
    $grid -> gdb_opt         = $gdb;
    $grid -> include_plugins = true;
    $grid -> title           = 'Edycja ustawień';
    $grid -> actions         = [
                                'save' => [
                                            'url'       => '/admin/settings/settings_save/',
                                            'back_url'  => '/admin/settings/view/'
                                          ]
    ];
    $grid -> external_code   = $out;
    echo $grid -> draw();
    ?>
    <script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
    <script>
      $(document).ready(function () {
        $('.popover-btn').popover(
                {
                  trigger: 'hover',
                  html: true
                });
      });
    </script>
    <style>
      #g-edit-save.btn-system{
        display: none;
      }
    </style>
    <style type="text/css">#g-edit-cancel { display: none; }</style>