<div class="panel panel-info panel-border top">
  <div class="panel-heading">
    <span class="panel-title">Edycja frazy: <u><?= $this -> phrase['phrase'];?></u></span>
  </div>
  <div class="panel-heading p5" style="height: auto;">
    <div class="row mb10 pl5">
      <div class="col col-xs-12">
        <?= \Html::button(
                    array(
                      'class' => 'btn btn-sm btn-success',
                      'text'  => 'Zatwierdź',
                      'js'    => 'checkForm( "formularz" );',
                      'icon'  => 'fa-check-circle mr5'
                    )
                );?>
        <?= \Html::button(
                    array(
                      'class' => 'btn btn-sm btn-danger',
                      'text'  => 'Anuluj',
                      'url'   => '/ranker/main_view/id=' . $this -> site_id,
                      'icon'  => 'fa-times mr5'
                    )
                );?>
      </div>
    </div>
  </div>
  <div class="panel-body">
    <form method="POST" action="/ranker/phrase_save/>" id="formularz" class="form-horizontal">
      <input type='hidden' name='phrase_id' value='<?= $this -> phrase['id'];?>'>
      <div class="row">
        <div class="col col-md-6">
          <? if ( $this -> phrase ):?>
            <?= \Html::input(
                        array(
                          'name'  => 'phrase',
                          'class' => 'require',
                          'value' => $this -> phrase['phrase'],
                          'label' => 'Fraza'
                        )
                    );?>
          <? else:?>
            <?= \Html::textarea(
                        array(
                          'name'  => 'phrase',
                          'class' => 'require',
                          'label' => 'Fraza'
                        )
                    );?>
          <? endif;?>
          <?= \Html::input(
                      array(
                        'name'  => 'localization',
                        'value' => $this -> phrase['localization'],
                        'label' => 'Lokalizacja'
                      )
                  );?>
          <?= \Html::input(
                      array(
                        'name'  => 'discount',
                        'value' => $this -> phrase['discount'],
                        'label' => 'Rabat w %',
                        'class' => 'number-format'
                      )
                  );?>
          <?= \Html::input(
                      array(
                        'name'  => 'date_start',
                        'value' => $this -> phrase['date_start'] != '0000-00-00' ? $this -> phrase['date_start'] : null,
                        'label' => 'Początek',
                        'class' => 'date'
                      )
                  );?>
          <?= \Html::input(
                      array(
                        'name'  => 'date_end',
                        'value' => $this -> phrase['date_end'] != '0000-00-00' ? $this -> phrase['date_end'] : null,
                        'label' => 'Koniec',
                        'class' => 'date'
                      )
                  );?>
          <?
            if ( is_array( $this -> sites ) ) foreach ( $this -> sites as $site )
              $sites[ $site['id'] ] = $site['name'];
          ?>

          <?= \Html::select(
                      array(
                        'name'    => 'site_id',
                        'label'   => 'Strona',
                        'value'   => $this -> site_id,
                        'values'  => $sites
                      )
                  );?>
          <hr />
          <?= \Html::input( [
                        'name'  => 'days_offset',
                        'value' => $this -> phrase['days_offset'],
                        'label' => 'Sprawdza co X dni'
                      ] );?>
          <?= \Html::input_switch( [
                        'name'    => 'to_all',
                        'label'   => 'Zastosuj do wszystkich',
                        'checked' => false,
                        'values'  => [
                          '0' => 'nie',
                          '1' => 'tak'
                        ]
                      ] );?>
        </div>
      </div>
  </div>
</div>