<? global $lang; ?>
<div class="row">
  <div class="col-12 col-lg-9" style="padding: 0 5px;">
    <div class="advert-details">
      <div class="top">
        <h1 class="name"><?= $this->advert['title']; ?></h1>
        <div class="top-content">
          <div class="row">
            <div class="col-md-6">
              <div class="advert-details-top-right">
                <div class="firm">
                  <a href="/pracodawca/<?= $this->advert['user_id']; ?>/<?= \S::seo($this->advert['firm_name_profile'], true); ?>"><?= $this->advert['firm_name_profile']; ?></a>
                </div>
                <div class="info">
                  <span class="date">
                    <i class="fa fa-calendar"></i><?= ucfirst($lang['opublikowano']); ?>: <?= date('Y-m-d', strtotime($this->advert['date_add'])); ?>
                  </span>
                </div>
                <div class="info-second">
                  <span class="place">
                    <a href="/oferty-pracy/<?= \S::seo($this->advert['country_name'], true); ?>" title="oferty pracy <?= $this->advert['country_name']; ?>"><?= $this->advert['country_name']; ?></a>
                    <? if ($this->advert['id_voivodeship']) : ?> - <?= \front\factory\Globelus::get_voivodeship_name($this->advert['id_voivodeship']); ?><? endif; ?> -
                      <?= $this->advert['city']; ?>
                  </span><br>
                  <span class="category">
                    <a href="/oferty-pracy/<?= \S::seo($this->advert['category_name'], true); ?>" title="oferty pracy <?= $this->advert['category_name']; ?>"><?= $this->advert['category_name']; ?></a>
                  </span>
                  <? if ( $this -> advert['id_position'] ):?><br>
                    <span class="position"><?= \front\factory\Globelus::position_name( $this -> advert['id_position'] );?></span>
                  <? endif;?>
                </div>
                <? if ($this->g_user and !$this->g_user['type']) : ?>
                  <form method="POST" action="<? if (in_array($this->advert['id'], $this->g_user['adverts'])) : ?>/globelusAdverts/remove_from_favorite/<? else : ?>/globelusAdverts/add_to_favorite/<? endif; ?>" id="advert-favorite">
                    <input type="hidden" name="redirect_url" value="<?= $_SERVER['REQUEST_URI']; ?>">
                    <input type="hidden" name="advert_id" value="<?= $this->advert['id']; ?>">
                    <a href="#" <? if (in_array($this->advert['id'], $this->g_user['adverts'])) : ?>class="active" <? endif; ?> onclick="$( '#advert-favorite' ).submit(); return false;">
                      <i class="fa fa-star" title="<? if (in_array($this->advert['id'], $this->g_user['adverts'])) : ?><?= $lang['usun-z-obserwowanych']; ?><? else : ?><?= $lang['dodaj-do-obserwowanych']; ?><? endif; ?>"></i>
                      <? if (in_array($this->advert['id'], $this->g_user['adverts'])) : ?><?= $lang['usun-z-obserwowanych']; ?><? else : ?><?= $lang['dodaj-do-obserwowanych']; ?><? endif; ?>
                    </a>
                  </form>
                <? endif; ?>
              </div>
            </div>
            <div class="col-md-6">
              <div class="logo-container">
                <div class="logo ">
                  <? if (file_exists(\front\factory\GlobelusFirms::logo_url($this->advert['user_id']))) : ?>
                    <img src="/logo/<?= $this->advert['user_id']; ?>/<?= \S::get_token(); ?>">
                  <? else : ?>
                    <img src="/images/no-logo.jpg">
                  <? endif; ?>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="icons">
          <? if ( trim( $this->advert['salary'] )):?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-money.svg">
              </div>
              <div class="_text">
                <?= $this -> advert['salary'];?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['overtime']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-time.svg">
              </div>
              <div class="_text">
                <?= $this->advert['overtime_quantity']; ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['accommodation']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-bed.svg">
              </div>
              <div class="_text">
                <?= $this->advert['accommodation_cost']; ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['travel_refund']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-plane.svg">
              </div>
              <div class="_text">
                refundacja przejazdu
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['work_type']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-plane.svg">
              </div>
              <div class="_text">
                <? $work_type = \front\factory\Globelus::work_types();
                echo $work_type[$this->advert['work_type']]; ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['without_experience']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-case.svg">
              </div>
              <div class="_text">
                <?= \S::lang('bez-doswiadczenia'); ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['without_language']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-lang.svg">
              </div>
              <div class="_text">
                <?= \S::lang('bez-znajomosci-jezyka'); ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['for_couples']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-couple.svg">
              </div>
              <div class="_text">
                <?= \S::lang('dla-par'); ?>
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['outside_ue']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-ue.svg">
              </div>
              <div class="_text">
                dla obywateli spoza UE
              </div>
            </div>
          <? endif; ?>
          <? if ($this->advert['without_driving_license']) : ?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-car.svg">
              </div>
              <div class="_text">
                bez prawa jazdy
              </div>
            </div>
          <? endif; ?>
        </div>
      </div>
      <?
        $img_header_url = \front\factory\GlobelusFirms::img_header_url( $this -> advert['user_id'] );
        $advert_add_img_top = \front\factory\GlobelusFirms::advert_add_img_top_url( $this -> advert['id'] );
        if ( file_exists( $advert_add_img_top ) ):
          echo '<div class="image_header"><img src="/advert_add_img_top/' . $this->advert['id'] . '/'. \S::get_token() . '"></div>';
        elseif ( file_exists( $img_header_url ) ):
          echo '<div class="image_header"><img src="/img_header/' . $this -> advert['user_id'] . '/'. \S::get_token() . '"></div>';
        endif;
      ?>
      <div class="content">
        <?
        $text = $this -> advert['text'];
        if (!$this->g_user) :
          $text = preg_replace('/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i', ' <a href="/logowanie">Zaloguj się aby zobaczyć adres email</a> ', $text);
          $text = preg_replace(
            '/(\+[0-9]{11}|\+[0-9]{2} [0-9]{9}|\+[0-9]{2} [0-9]{3} [0-9]{3} [0-9]{3}|\+[0-9]{2} [0-9]{3}-[0-9]{3}-[0-9]{3}|[0-9]{3} [0-9]{3} [0-9]{3}|[0-9]{4} [0-9]{8})/i',
            ' <a href="/logowanie">Zaloguj się aby zobaczyć numer telefonu</a> ',
            $text
          );
        endif;
        $text = \S::clear_advert_text( $text );
        echo $text;
        ?>
      </div>
      <?
        $img_bottom_url = \front\factory\GlobelusFirms::img_bottom_url( $this -> advert['user_id'] );
        $advert_add_img_bottom = \front\factory\GlobelusFirms::advert_add_img_bottom_url( $this -> advert['id'] );
        if ( file_exists( $advert_add_img_bottom ) ):
          echo '<div class="image_bottom"><img src="/advert_add_img_bottom/' . $this->advert['id'] . '/'. \S::get_token() . '"></div>';
        elseif ( file_exists( $img_bottom_url ) ):
          echo '<div class="image_bottom"><img src="/img_bottom/' . $this -> advert['user_id'] . '/'. \S::get_token() . '"></div>';
        endif;
      ?>
      <? if ($this->advert['clauses'] === 'test' ) : ?>
        <div class="content clauses">
          <?= $this->advert['clauses']; ?>
        </div>
      <? endif; ?>
      <? if ( $this->advert['contact_person'] ):?>
        <div class="content person">
          <? if ( !$this -> g_user['id'] ):?>
            <div class="_content_nologged">
              <div class="_title">Osoba rekrutująca na stanowisko</div>
              <div class="_subtitle">Zaloguj się aby zobaczyć dane kontaktowe</div>
            </div>
          <? else:?>
            <div class="_content">
              <div class="_icon">
                <img src="/images/icon-user-square.svg" alt="Osoba rekrutująca na stanowisko" />
              </div>
              <div class="_text">
                <p><strong>Osoba rekrutująca na stanowisko:</strong></p>
                <p><?= $this->advert['contact_person']; ?><br />
                  <? if (!$this->g_user) : ?>
                    <a href="/logowanie">Zaloguj się aby zobaczyć adres email</a><br />
                    <a href="/logowanie">Zaloguj się aby zobaczyć numer telefonu</a><br />
                  <? else : ?>
                    <?= $this->advert['phone']; ?><br />
                    <?= $this->advert['email']; ?><br />
                  <? endif; ?>
                </p>
              </div>
            </div>
          <? endif;?>
        </div>
      <? endif; ?>
      <a href="<?= $this->advert['aplication_link'] != '' ? $this->advert['aplication_link'] : '/aplikuj/' . $this -> advert['id'];?>" class="aplication-link btn btn-red mt15 btn_aplikuj">Aplikuj teraz</a>
    </div>
  </div>
  <div class="col-12 col-lg-3" style="padding: 0 5px;">
    <a href="<?= $this->advert['aplication_link'] != '' ? $this->advert['aplication_link'] : '/aplikuj/' . $this -> advert['id'];?>" class="btn btn-red btn_aplikuj" <?= $this -> advert['aplication_link'] ? 'target="_blank"' : '';?>>Aplikuj</a>
    <div class="row advert_details_boxes">
      <div class="col-12">
        <div class="mini-box mt10 text-center">
          <form method="POST" action="/oferty-pracy">
            <input type="hidden" name="filtr" value="t">
            <input type="hidden" name="k" value="<?= $this->advert['firm_name_profile']; ?>">
            <a href="#" class="action" onclick="$( this ).parent( 'form' ).submit(); return false;">
              <i class="fa fa-bars"></i>
              <?= ucfirst($lang['inne-oferty-tego-pracodawcy']); ?>
            </a>
          </form>
        </div>
      </div>
      <div class="col-12">
        <div class="mini-box mt10 text-center">
          <a href="/pracodawca/<?= $this->advert['user_id']; ?>/<?= \S::seo($this->advert['firm_name_profile'], true); ?>" class="action">
            <i class="fa fa-user"></i>
            <?= ucfirst($lang['zobacz-profil-pracodawcy']); ?>
          </a>
        </div>
      </div>
      <div class="col-12">
        <div class="mini-box mt10 text-center">
          <div class="social-icons">
            <a class="fb" href="http://www.facebook.com/sharer.php?u=<?= \S::get_domain_url($_SERVER['SERVER_NAME']); ?>/oferta/<?= $this->advert['id']; ?>/<?= \S::seo($this->advert['title'], true); ?>/" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" title="facebook" target="_blank" rel="nofollow">
              <img src="/images/system/logo-facebook.jpg" alt="facebook" />
            </a>
            <a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?= \S::get_domain_url($_SERVER['SERVER_NAME']); ?>/oferta/<?= $this->advert['id']; ?>/<?= \S::seo($this->advert['title'], true); ?>/" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" title="pinterest" target="_blank" rel="nofollow">
              <img src="/images/system/logo-pinterest.jpg" alt="pinterest" />
            </a>
            <a class="twitter" href="http://twitter.com/share?url=<?= \S::get_domain_url($_SERVER['SERVER_NAME']); ?>/oferta/<?= $this->advert['id']; ?>/<?= \S::seo($this->advert['title'], true); ?>/" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=600');return false;" title="twitter" target="_blank" rel="nofollow">
              <img src="/images/system/logo-twitter.jpg" alt="twitter" />
            </a>
            <a class="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=<?= \S::get_domain_url($_SERVER['SERVER_NAME']); ?>/oferta/<?= $this->advert['id']; ?>/<?= \S::seo($this->advert['title'], true); ?>/" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=850');return false;" title="linked in" target="_blank" rel="nofollow">
              <img src="/images/system/logo-linkedin.jpg" alt="linkedin" />
            </a>
            <a class="gp" href="https://plus.google.com/share?url=<?= \S::get_domain_url($_SERVER['SERVER_NAME']); ?>/oferta/<?= $this->advert['id']; ?>/<?= \S::seo($this->advert['title'], true); ?>/" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" title="google+" target="_blank" rel="nofollow">
              <img src="/images/system/logo-google.jpg" alt="google+" />
            </a>
          </div>
        </div>
      </div>
      <? if (count( $this -> similar_adverts)) : ?>
        <div class="col-12">
          <div class="mini-box vertical similar-adverts">
            <div class="title small">
              Podobne oferty
            </div>
            <ul>
              <? foreach ($this->similar_adverts as $advert_id) : ?>
                <? $advert = \front\factory\GlobelusAdverts::advert_details( $advert_id );?>
                <li>
                  <a href="/oferta/<?= $advert['id']; ?>/<?= \S::seo($advert['title'], true); ?>" title="Ogłoszenie: <?= addslashes($advert['title']); ?>"><?= $advert['title']; ?></a>
                  <div class="_firm">
                    <div class="_image">
                      <? if (file_exists( \front\factory\GlobelusFirms::logo_url($advert['user_id'] ) ) ):?>
                        <img src="/logo/<?= $advert['user_id']; ?>/<?= \S::get_token(); ?>">
                      <? else : ?>
                        <img src="/images/no-logo.jpg">
                      <? endif; ?>
                    </div>
                    <div class="_name">
                      <div class="place">
                        <i class="fa fa-map-marker"></i>
                        <a href="/oferty-pracy/<?= \S::seo( $advert['country_name'], true); ?>" title="oferty pracy <?= $advert['country_name']; ?>"><?= $advert['country_name']; ?></a>
                        <? if ($advert['id_voivodeship']) : ?> - <?= \front\factory\Globelus::get_voivodeship_name($advert['id_voivodeship']); ?><? endif; ?> - <?= $advert['city']; ?>
                      </div>
                      <a href="/pracodawca/<?= $this->advert['user_id']; ?>/<?= \S::seo($this->advert['firm_name_profile'], true); ?>"><?= $this->advert['firm_name_profile']; ?></a>
                    </div>
                  </div>
                  <div class="_bottom">
                    <!-- button aplikuj -->
                    <a href="<?= $advert['aplication_link'] != '' ? $advert['aplication_link'] : '/aplikuj/' . $advert['id'];?>">Aplikuj szybko</a>
                  </div>
                </li>
              <? endforeach; ?>
            </ul>
          </div>
        </div>
      <? endif; ?>
    </div>
  </div>
</div>
  <script class="footer" type="text/javascript">
    $(function() {
      $('body').on('submit', '#advert-contact', function(e) {
        if (!($('#cv')[0].files[0].size < 5242880)) {
          e.preventDefault();
          $.alert({
            title: '<?= ucfirst($lang['blad']); ?>',
            icon: 'fa fa-exclamation',
            content: '<?= $lang['plik-cv-jest-zbyt-duzy']; ?>',
            type: 'blue',
            closeIcon: true,
            closeIconClass: 'fa fa-close',
            typeAnimated: true,
            animation: 'opacity',
            autoClose: 'confirm|10000',
            columnClass: 'large',
            theme: 'modern',
            buttons: {
              confirm: {
                text: '<?= $lang['zamknij']; ?>',
                btnClass: 'btn-blue',
                keys: ['enter'],
                action: function() {}
              }
            }
          });
        }
      });
    });
  </script>
  <?
  if (!$this->g_user['id'] or $this->g_user['id'] != $this->advert['user_id'])
    \front\factory\GlobelusAdverts::advert_visits_increase($this->advert['id']);
  ?>