<? global $config;?>
<div class="panel panel-info panel-border top">
  <div class="panel-heading" style="height: auto; padding-bottom: 4px;">
    <div class="row" style="color: #666666;">
      <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 text-centred-xs text-centred-sm">
        <div class="btn-group">
          <?= \Html::button(
                      array(
                        'class' => 'btn-sm btn-default btn-gradient',
                        'title' => 'Poprzednia strona',
                        'url'   => '/?p=client_sites&id=' . $this -> _prev_site_id,
                        'icon'  => 'fa-backward'
                      )
                  );?>
          <?= \Html::button(
                      array(
                        'class' => 'btn-sm btn-default btn-gradient',
                        'title' => 'Następna strona',
                        'url'   => '/?p=client_sites&id=' . $this -> _next_site_id,
                        'icon'  => 'fa-forward'
                      )
                  );?>
        </div>
        <select name="page" class="form-control ranker-select" id="page" onChange="var id = $(this).val(); document.location.href='./?id=' + id;" style='max-width: 250px;'>
          <?
          if ( is_array ( $this -> _sites ) ) foreach ( $this -> _sites as $site )
          {
            if ( $this -> _site['id'] == $site['id'] )
              $name = $site['name'];
            ?>
              <option value="<?= $site['id'];?>" <? if ( $this -> _site['id'] == $site['id'] ) echo 'selected="selected"';?>>
                <?= $site['name'];?>
              </option>
            <?
          }
          ?>
        </select>
      </div>
      <div class="col-xs-12 col-sm-4 col-md-4 col-lg-2 text-centred-xs hidden-md hidden-xs hidden-sm">
        <a href="http://<?= $this -> _site['url'];?>" target="_blank"><?= $this -> _site['url'];?></a>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 text-centred-xs text-centred-sm text-right">
        <select name="month_global" class="form-control ranker-select" id="month_global" onChange="document.location.href='./?p=client_sites&id=<?= $this -> _site['id'];?>&year=' + $( '#year_global' ).val() + '&month=' + $( this ).val();">
          <option value="01" <? if ( $this -> _month == '01' ) echo 'selected="selected"'; ?>>Styczeń</option>
          <option value="02" <? if ( $this -> _month == '02' ) echo 'selected="selected"'; ?>>Luty</option>
          <option value="03" <? if ( $this -> _month == '03' ) echo 'selected="selected"'; ?>>Marzec</option>
          <option value="04" <? if ( $this -> _month == '04' ) echo 'selected="selected"'; ?>>Kwiecień</option>
          <option value="05" <? if ( $this -> _month == '05' ) echo 'selected="selected"'; ?>>Maj</option>
          <option value="06" <? if ( $this -> _month == '06' ) echo 'selected="selected"'; ?>>Czerwiec</option>
          <option value="07" <? if ( $this -> _month == '07' ) echo 'selected="selected"'; ?>>Lipiec</option>
          <option value="08" <? if ( $this -> _month == '08' ) echo 'selected="selected"'; ?>>Sierpień</option>
          <option value="09" <? if ( $this -> _month == '09' ) echo 'selected="selected"'; ?>>Wrzesień</option>
          <option value="10" <? if ( $this -> _month == '10' ) echo 'selected="selected"'; ?>>Październik</option>
          <option value="11" <? if ( $this -> _month == '11' ) echo 'selected="selected"'; ?>>Listopad</option>
          <option value="12" <? if ( $this -> _month == '12' ) echo 'selected="selected"'; ?>>Grudzień</option>
        </select>
        <select name="year_global" id="year_global" class="form-control ranker-select" onChange="document.location.href='./?p=client_sites&id=<?= $this -> _site['id'];?>&year=' + $( this ).val() + '&month=' + $( '#month_global' ).val();">
          <? for ( $i = date( 'Y') - 2; $i <= date( 'Y') + 2; $i++ ):?>
            <option value="<?= $i;?>" <? if ( $i == $this -> _year ) echo 'selected="selected"'; ?>><?=$i;?></option>
          <? endfor;?>
        </select>
      </div>
    </div>
  </div>
</div>
<div class="panel hidden-sm hidden-md hidden-lg">
  <div class="panel-body p0">
    <div class="row">
      <?
        if ( is_array( $this -> _phrases ) ) foreach ( $this -> _phrases as $phrase )
        {
          $phrase_class = '';

          if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
            $phrase_class = 'text-danger';

          if ( $phrase['date_start'] and new DateTime( $phrase['date_start'] ) > new DateTime( date( 'Y-m-d' ) ) ) 
            $phrase_class = 'text-danger';

          $pos = $phrase['positions'][ date( 'Y-m-d' ) ]['position'];

          if ( $pos <= 10 )
            $start = 0;
          else
          {
            $start = 10 * floor( $pos / 10 );
            if ( $pos%10 == 0 )
              $start = $start - 10;
          }
          ?>
          <div class="col-xs-12">
            <div style="<? if ( $phrase['color'] ) echo 'border-top: 5px solid ' . $phrase['color'];?>">
              <div class="text-left p5" >
                <a href="http://www.google.pl/search?q=<?= urlencode( $phrase['phrase'] );?>&num=10&ie=utf8&hl=pl&start=<?= $start;?><? if ( $phrase['localization'] ) echo '&uule=' . \factory\Ranker::uule( $phrase['localization'] );?>" target="_blank" title="<?= $phrase['phrase'];?>" class="<?= $phrase_class;?>">
                  <?= $phrase['phrase'];?>
                </a>
                <div class="page-options fr">
                  <a href="./?rw=edit_phrase&phrase_id=<?= $phrase['id'];?>&id=<?= $this -> _site['id'];?>" class="tip a-icon" title="Edytuj wybraną frazę">
                    <i class="fa fa-file-text text-dark" style="font-size: 14px; margin: 0 5px;"></i>
                  </a>
                  <a href="./?rw=edit_costs_reseller&phrase_id=<?= $phrase['id'];?>&id=<?= $this -> _site['id'];?>" class="tip a-icon" title="Definiuj własne zakresy">
                    <i class="fa fa-list text-dark" style="font-size: 14px; margin: 0 5px; position: relative; top: 1px;"></i>
                  </a>
                </div>
                <a href="<?= $phrase['last_url'];?>" class="text-muted small clearfix" target="_blank" title="<?= $phrase['last_url'];?>">
                  <?= $phrase['last_url'];?>
                </a>
              </div>
            </div>
          </div>
          <div class="col-xs-12">
            <div class="table-responsive" <? if ( $z++ < 1 ):?>id="positions-xs"<? endif;?>>
              <?
              $start  = date( 'Y-m-d', mktime( 0, 0, 0, $this -> _month, 1, $this -> _year ) );
              $days   = date( 't', strtotime( $start ) );
              ?>
              <table class="table table-bordered table-striped table-condensed table-hover table-positions">
                <thead>
                  <tr>
                    <th class="text-center" <? if ( $z < 2 ):?>id="date-xs-<?= date( 'Y-m-d', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );?>"<? endif;?>><?= date( 't', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );?></th>
                    <? for ( $i = 1; $i <= $days; $i++ ):?>
                      <th class="text-center" <? if ( $z < 2 ):?>id="date-xs-<?= date( 'Y-m-d', strtotime( $this -> _year . '-' . $this -> _month . '-' . $i ) );?>"<? endif;?>><?= $i;?></th>
                    <? endfor;?>
                  </tr>
                </thead>
                <tbody>
                  <tr style="height: 45px;">
                    <?
                      $date_tmp = date( 'Y-m-t', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );

                      $pos = $phrase['positions'][ $date_tmp ]['position'];
                      $map = $phrase['positions'][ $date_tmp ]['map'];
                      $url = $phrase['positions'][ $date_tmp ]['url'];

                      $class  = 'position';
                      $text   = '';
                      $end    = '';

                      if ( $pos == 1 )
                        $class = 'pos_1';
                      if ( $pos == 2 || $pos == 3 )
                        $class = 'pos_2';
                      if ( $pos >= 4 && $pos <= 6 )
                        $class = 'pos_4';
                      if ( $pos >= 7 && $pos <= 10 )
                        $class = 'pos_7';
                      if ( $pos >= 11 && $pos <= 20 )
                        $class = 'pos_11';
                      if ( $pos == 0 || $pos >= 21 )
                        $class = 'pos_21';

                      if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
                        $class = 'end position';

                      if ( $phrase['date_start'] and new DateTime( $phrase['date_start'] ) > new DateTime( date( 'Y-m-d' ) ) ) 
                        $class = 'end position';

                      if ( $pos != '' )
                        $pos = $pos;
                      else
                        $pos = '-';
                    ?>
                    <td class="position text-center small <?= $class;?>" id="<?= $phrase['id'] . '-' .  $date_tmp;?>" phrase="<?= $phrase['id'];?>" date="<?= $date_tmp;?>" <? if ( $map ):?> style="box-shadow: inset 0 0 10px rgba( 0, 0, 0, 0.4 );"<? endif;?> title="<?= $url;?>">
                      <span><?= $pos;?></span>
                    </td>
                    <? for ( $i = 1; $i <= $days; $i++ ):
                        $i < 10 ? $d = '0' . $i : $d = $i;  

                        $pos = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['position'];
                        $map = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['map'];
                        $url = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['url'];

                        $class  = 'position';
                        $text   = '';
                        $end    = '';

                        if ( $pos == 1 )
                          $class = 'pos_1';
                        if ( $pos == 2 || $pos == 3 )
                          $class = 'pos_2';
                        if ( $pos >= 4 && $pos <= 6 )
                          $class = 'pos_4';
                        if ( $pos >= 7 && $pos <= 10 )
                          $class = 'pos_7';
                        if ( $pos >= 11 && $pos <= 20 )
                          $class = 'pos_11';
                        if ( $pos == 0 || $pos >= 21 )
                          $class = 'pos_21';

                        if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
                          $class = 'end position';

                        if ( $phrase['date_start'] and new DateTime( $phrase['date_start'] ) > new DateTime( date( 'Y-m-d' ) ) ) 
                          $class = 'end position';

                        if ( $pos != '' )
                          $pos = $pos;
                        else
                          $pos = '-';
                        ?>
                        <td class="position text-center small <?= $class;?>" id="<?= $phrase['id'] . '-' .  $this -> _year . '-' . $this -> _month . '-' . $d;?>" phrase="<?= $phrase['id'];?>" date="<?= $this -> _year . '-' . $this -> _month . '-' . $d;?>" <? if ( $map ):?> style="box-shadow: inset 2px 2px 10px rgba( 0, 0, 0, 0.5 );"<? endif;?> title="<?= $url;?>">
                          <span><?= $pos;?></span>
                        </td>
                    <? endfor;?>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
          <?
        }
      ?>
    </div>
  </div>
</div>
<div class="panel hidden-xs">
  <div class="panel-body" style="padding: 0px;">
    <div class="row">
      <div class="col-sm-5 col-md-4 col-lg-3">
        <table class="table table-bordered table-striped table-condensed" id="table-phrases">
          <thead>
            <tr>
              <th class="title">Fraza</th>
            </tr>
          </thead>
          <tbody>
            <?
            if ( is_array( $this -> _phrases ) ) foreach ( $this -> _phrases as $phrase )
            {
              $phrase_class = '';

              if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
                $phrase_class = 'text-danger';

              if ( $phrase['date_start'] and new DateTime( $phrase['date_start'] ) > new DateTime( date( 'Y-m-d' ) ) ) 
                $phrase_class = 'text-danger';

              $pos = $phrase['positions'][ date( 'Y-m-d' ) ]['position'];

              if ( $pos <= 10 )
                $start = 0;
              else
              {
                $start = 10 * floor( $pos / 10 );
                if ( $pos%10 == 0 )
                  $start = $start - 10;
              }
              ?>
              <tr style="height: 45px;">
                <td>
                  <div class="text-right" >
                    <a href="http://www.google.pl/search?q=<?= urlencode( $phrase['phrase'] );?>&num=10&ie=utf8&hl=pl&start=<?= $start;?><? if ( $phrase['localization'] ) echo '&uule=' . \factory\Ranker::uule( $phrase['localization'] );?>" target="_blank" title="<?= $phrase['phrase'];?>" class="a-icon <?= $phrase_class;?>">
                      <?= $phrase['phrase'];?>
                    </a>
                    <div class="page-options">
                      <a href="./?rw=edit_phrase&phrase_id=<?= $phrase['id'];?>&id=<?= $this -> _site['id'];?>" class="tip a-icon" title="Edytuj wybraną frazę">
                        <i class="fa fa-file-text text-dark" style="font-size: 14px; margin: 0 5px;"></i>
                      </a>
                      <a href="./?rw=edit_costs_reseller&phrase_id=<?= $phrase['id'];?>&id=<?= $this -> _site['id'];?>" class="tip a-icon" title="Definiuj własne zakresy">
                        <i class="fa fa-list text-dark" style="font-size: 14px; margin: 0 5px; position: relative; top: 1px;"></i>
                      </a>
                    </div>
                    <a href="<?= $phrase['last_url'];?>" class="text-muted small clearfix phrase_url" target="_blank" title="<?= $phrase['last_url'];?>">
                      <?= $phrase['last_url'];?>
                    </a>
                  </div>
                </td>
              </tr>
              <?
            }
            ?>
          </tbody>
        </table>
      </div>
      <div class="col-sm-7 col-md-8 col-lg-9">
        <div class="table-responsive" id="positions-not-xs">
          <?
          $start  = date( 'Y-m-d', mktime( 0, 0, 0, $this -> _month, 1, $this -> _year ) );
          $days   = date( 't', strtotime( $start ) );
          ?>
          <table class="table table-bordered table-striped table-condensed table-hover table-positions">
            <thead>
              <tr>
                <th class="text-center" id="date-<?= date( 'Y-m-t', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );?>"><?= date( 't', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );?></th>
                <? for ( $i = 1; $i <= $days; $i++ ):?>
                  <th class="text-center" id="date-<?= date( 'Y-m-d', strtotime( $this -> _year . '-' . $this -> _month . '-' . $i ) );?>"><?= $i;?></th>
                <? endfor;?>
              </tr>
            </thead>
            <tbody>
              <? if ( is_array( $this -> _phrases ) ):?>
                <? foreach ( $this -> _phrases as $phrase ):?>
                  <tr style="height: 45px;">
                    <?
                      $date_tmp = date( 'Y-m-t', strtotime( '-1 month', strtotime( $this -> _year . '-' . $this -> _month ) ) );

                      $pos = $phrase['positions'][ $date_tmp ]['position'];
                      $map = $phrase['positions'][ $date_tmp ]['map'];
                      $url = $phrase['positions'][ $date_tmp ]['url'];

                      $class  = 'position';
                      $text   = '';
                      $end    = '';

                      if ( $pos == 1 )
                        $class = 'pos_1';
                      if ( $pos == 2 || $pos == 3 )
                        $class = 'pos_2';
                      if ( $pos >= 4 && $pos <= 6 )
                        $class = 'pos_4';
                      if ( $pos >= 7 && $pos <= 10 )
                        $class = 'pos_7';
                      if ( $pos >= 11 && $pos <= 20 )
                        $class = 'pos_11';
                      if ( $pos == 0 || $pos >= 21 )
                        $class = 'pos_21';

                      if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
                        $class = 'end position';

                      if ( $pos != '' )
                        $pos = $pos;
                      else
                        $pos = '-';
                    ?>
                    <td class="position text-center small <?= $class;?>" id="<?= $phrase['id'] . '-' .  $date_tmp;?>" phrase="<?= $phrase['id'];?>" date="<?= $date_tmp;?>" <? if ( $map ):?> style="box-shadow: inset 0 0 10px rgba( 0, 0, 0, 0.4 );"<? endif;?> title="<?= $url;?>">
                      <span><?= $pos;?></span>
                    </td>
                  <? for ( $i = 1; $i <= $days; $i++ ):
                      $i < 10 ? $d = '0' . $i : $d = $i;  

                      $pos = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['position'];
                      $map = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['map'];
                      $url = $phrase['positions'][ $this -> _year . '-' . $this -> _month . '-' . $d ]['url'];

                      $class  = 'position';
                      $text   = '';
                      $end    = '';

                      if ( $pos == 1 )
                        $class = 'pos_1';
                      if ( $pos == 2 || $pos == 3 )
                        $class = 'pos_2';
                      if ( $pos >= 4 && $pos <= 6 )
                        $class = 'pos_4';
                      if ( $pos >= 7 && $pos <= 10 )
                        $class = 'pos_7';
                      if ( $pos >= 11 && $pos <= 20 )
                        $class = 'pos_11';
                      if ( $pos == 0 || $pos >= 21 )
                        $class = 'pos_21';

                      if ( new DateTime( $phrase['date_end'] ) < new DateTime( date( 'Y-m-d' ) ) ) 
                        $class = 'end position';

                      if ( $pos != '' )
                        $pos = $pos;
                      else
                        $pos = '-';
                      ?>
                      <td class="position text-center small <?= $class;?>" id="<?= $phrase['id'] . '-' .  $this -> _year . '-' . $this -> _month . '-' . $d;?>" phrase="<?= $phrase['id'];?>" date="<?= $this -> _year . '-' . $this -> _month . '-' . $d;?>" <? if ( $map ):?> style="box-shadow: inset 2px 2px 10px rgba( 0, 0, 0, 0.5 );"<? endif;?> title="<?= $url;?>">
                        <span><?= $pos;?></span>
                      </td>
                  <? endfor;?>
                </tr>
                <? endforeach;?>
              <? endif;?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
<? if ( is_array( $this -> _phrases ) ):?>
  <div class="alert alert-dark light p5">
    <small>Stawki podstawowe</small>
  </div>
  <div class="row">
    <?
      $suma = 0;
      foreach ( $this -> _phrases as $phrase )
      {
        $discount = '';
        
        if ( $this -> _site['discount'] > 0 )
          $discount = $this -> _site['discount'];

        if ( $phrase['discount'] > 0 )
          $discount = $phrase['discount'];
        
        if ( is_array( $phrase['prices'] ) ) 
        {
          ?>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div class="panel panel-primary">
              <div class="panel-heading small">
                <small><?= $phrase['phrase'];?> <? if ( $discount > 0 ):?><span class="fr">rabat <?= $discount;?>%</span><? endif;?></small>
              </div>
              <div class="panel-body p0">
                <?
                  if ( is_array( $phrase['prices'] ) ) 
                  {
                    $sum = 0;
                    ?>
                    <table class="table table-condensed table-bordered table-striped">
                      <thead>
                        <tr>
                          <td class="text-right">Przedział</td>
                          <td class="text-right">Stawka</td>
                          <td class="text-right">Ilość dni</td>
                          <td class="text-right">Należność</td>
                        </tr>
                      </thead>
                      <tbody>
                        <?
                        foreach ( $phrase['prices'] as $price )
                        {
                          $price_c  = \S::number( $price['price'] - \S::number( $price['price'] * $discount / 100 ) );                    
                          ?>
                          <tr <? if ( !$price['count'] ):?> style="background: #efefef;"<? endif;?>>
                            <td class="text-right">
                              <?= $price['start'];?> - <?= $price['end'];?>
                            </td>
                            <td class="text-right">
                              <?= \S::number_display( $price_c );?>
                            </td>
                            <td class="text-right">
                              <?= $price['count'];?>
                            </td>
                            <td class="text-right">
                              <?= \S::number_display( $price_c * $price['count'] );?>
                            </td>
                          </tr>
                          <?
                          $sum  = $sum + $price_c * $price['count'];
                          $suma = $suma + $price_c * $price['count'];
                        }
                        ?>
                        <tr>
                          <td colspan="3" class="text-right">Suma:</td>
                          <td class="alert-dark dark text-right"><?= \S::number_display( $sum );?></td>
                        </tr>
                      </tbody>
                    </table>
                    <?
                  }
                ?>
              </div>
            </div>
          </div>
          <?
        }
      }
    ?>
  </div>
  <div class="row">
    <? if ( $suma ):?>
      <div class="col-md-3">
        <div class="panel panel-dark">
          <div class="panel-heading small">
            <small>Razem netto: <?= \S::number_display( $suma );?></small>
          </div>
        </div>
      </div>
      <div class="col-md-3">
        <div class="panel panel-dark">
          <div class="panel-heading small">
            <small>Razem brutto: <?= \S::number_display( $suma * $config['profit']['vat'] );?></small>
          </div>
        </div>
      </div>
    <? endif;?>
  </div>
  <div class="alert alert-dark light p5">
    <small>Stawki resellera</small>
  </div>
  <div class="row">
      <?
      $suma = 0;
      if ( is_array( $this -> _phrases_reseller ) ) foreach ( $this -> _phrases_reseller as $phrase )
      {
        $discount = '';

        if ( $phrase['discount'] )
          $discount = $phrase['discount'];
        
        if ( is_array( $phrase['prices'] ) ) 
        {
          ?>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div class="panel panel-primary">
              <div class="panel-heading small">
                <small><?= $phrase['phrase'];?> <? if ( $discount > 0 ):?><span class="text-dark">(rabat <?= $discount;?>%)</span><? endif;?></small>
              </div>
              <div class="panel-body p0">
                <?
                  if ( is_array( $phrase['prices'] ) ) 
                  {
                    $sum = 0;
                    ?>
                    <table class="table table-condensed table-bordered table-striped">
                      <thead>
                        <tr>
                          <td class="text-right">Przedział</td>
                          <td class="text-right">Stawka</td>
                          <td class="text-right">Ilość dni</td>
                          <td class="text-right">Należność</td>
                        </tr>
                      </thead>
                      <tbody>
                        <?
                        foreach ( $phrase['prices'] as $price )
                        {
                          $price_c  = \S::number( $price['price'] - \S::number( $price['price'] * $discount / 100 ) );                    
                          ?>
                          <tr <? if ( !$price['count'] ):?> style="background: #efefef;"<? endif;?>>
                            <td class="text-right">
                              <?= $price['start'];?> - <?= $price['end'];?>
                            </td>
                            <td class="text-right">
                              <?= \S::number_display( $price_c );?>
                            </td>
                            <td class="text-right">
                              <?= $price['count'];?>
                            </td>
                            <td class="text-right">
                              <?= \S::number_display( $price_c * $price['count'] );?>
                            </td>
                          </tr>
                          <?
                          $sum  = $sum + $price_c * $price['count'];
                          $suma = $suma + $price_c * $price['count'];
                        }
                        ?>
                        <tr>
                          <td colspan="3" class="text-right">Suma:</td>
                          <td class="alert-dark dark text-right"><?= \S::number_display( $sum );?></td>
                        </tr>
                      </tbody>
                    </table>
                    <?
                  }
                ?>
              </div>
            </div>
          </div>
          <?
        }
      }
    ?>
  </div>
  <div class="row">
    <? if ( $suma ):?>
      <div class="col-md-3">
        <div class="panel panel-dark">
          <div class="panel-heading small">
            <small>Razem netto: <?= \S::number_display( $suma );?></small>
          </div>
        </div>
      </div>
      <div class="col-md-3">
        <div class="panel panel-dark">
          <div class="panel-heading small">
            <small>Razem brutto: <?= \S::number_display( $suma * $config['profit']['vat'] );?></small>
          </div>
        </div>
      </div>
    <? endif;?>
  </div>
<? endif;?>
<script type="text/javascript">
  $( document ).ready( function() 
  {    
    if ( $( '#positions-not-xs' ).hasScrollBar() === true )
    {
      $( '#positions-not-xs' ).animate( { scrollLeft: $( '#date-<?= date( 'Y-m-d' );?>' ).position().left - 50 }, 500);
    }
    
    if ( $( '#positions-xs' ).hasScrollBar() === true )
    {
      $( '.hidden-sm .table-responsive' ).animate( { scrollLeft: $( '#date-xs-<?= date( 'Y-m-d' );?>' ).position().left - 50 }, 500);
    }
    
    $( '.phrase_url' ).css( 'width', $( '#table-phrases tr:first-child td:first-child' ).width() + 'px' ).css( 'display', 'block' );
  });
</script>