<? global $lang;?>
<div class="candidate-details">
  <div class="top">
    <div class="avatar-container">
      <h1 class="name"><?= htmlspecialchars( $this -> candidate['surname'] );?> <?= htmlspecialchars( $this -> candidate['name'] );?></h1>
      <div class="avatar">
        <? if ( file_exists( \front\factory\GlobelusCandidates::avatar_url( $this -> candidate['id'] ) ) ):?>
          <img src="/avatar/<?= $this -> candidate['id'];?>/<?= \S::get_token();?>">
        <? else:?>
          <img src="/images/no-avatar.png">
        <? endif;?>
      </div>
    </div>
    <div class="info">
      <?= $lang['tel.'];?> <?= $this -> candidate['phone'];?> | <?= $lang['email'];?>: <a href="mailto:<?= $this -> candidate['email'];?>"><?= $this -> candidate['email'];?></a>
    </div>
    <div class="info-second">
      <?= $lang['plec'];?>:
      <strong>
        <?
          if ( $this -> candidate['sex'] == '1' )
            echo $lang['mezczyzna'];
          else if ( $this -> candidate['sex'] == '0' )
            echo $lang['kobieta'];
          else
            echo '-';
        ?>
      </strong>
      <? if ( $this -> candidate['date_of_birth'] and $this -> candidate['date_of_birth'] != '1970-01-01' ):?>
        , <?= $lang['wiek'];?>: <strong><?= $age = \S::date_diff( $this -> candidate['date_of_birth'], date( 'Y-m-d H:i:s' ), 60 * 60 * 24 * 365.25 );?> <?= \front\factory\Globelus::age_word_translations( $age );?></strong>
      <? endif;?>
    </div>
    <? if ( $this -> g_user and $this -> g_user['type'] ):?>
      <form method="POST" action="<? if ( in_array( $this -> candidate['id'], $this -> g_user['candidates'] ) ):?>/globelusFirms/candidate_remove_from_favorite/<? else:?>/globelusFirms/candidate_add_to_favorite/<? endif;?>" id="candidate-favorite">
        <input type="hidden" name="redirect_url" value="<?= $_SERVER['REQUEST_URI'];?>">
        <input type="hidden" name="candidate_id" value="<?= $this -> candidate['id'];?>">
        <a href="#" <? if ( in_array( $this -> candidate['id'], $this -> g_user['candidates'] ) ):?>class="active"<? endif;?> onclick="$( '#candidate-favorite' ).submit(); return false;">
          <i class="fa fa-star" title="<? if ( in_array( $this -> candidate['id'], $this -> g_user['candidates'] ) ):?><?= $lang['usun-z-obserwowanych'];?><? else:?><?= $lang['dodaj-do-obserwowanych'];?><? endif;?>"></i>
          <? if ( in_array( $this -> candidate['id'], $this -> g_user['candidates'] ) ):?><?= $lang['usun-z-obserwowanych'];?><? else:?><?= $lang['dodaj-do-obserwowanych'];?><? endif;?>
        </a>
      </form>
    <? endif;?>
  </div>
  <div class="content">
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4">Chętnie podejmę pracę na stanowisku:</label>
          <div class="col-12 col-sm-8">
            <? if ( !$this -> candidate['inexperience'] ):?>
              <? $positions_experience = \front\factory\Globelus::positions_experience();?>
              <?
                if ( is_array( $this -> candidate['positions'] ) and count( $this -> candidate['positions'] ) ):
                  echo '<p class="mb0">';
                  foreach ( $this -> candidate['positions'] as $position ):
                    echo ' ● <strong>'; if ( !$position['id_position'] ) echo $position['position']; if ( $position['id_position'] ) echo \front\factory\Globelus::position_name( $position['id_position'] ); echo '</strong>'; if ( $position['experience'] ) echo ' - ' . $lang['moj-staz-na-tym-stanowisku'] . ' ' . $positions_experience[ $position['experience'] ];
                    if ( $position != end( $cv['positions'] ) )
                      echo '<br />';
                  endforeach;
                  echo '</p>';
                endif;
              ?>
            <? else:?>
              <?= $lang['brak-doswiadczenia'];?>
            <? endif;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['szukam-pracy-w'] );?>:</label>
          <div class="col-12 col-sm-8">
            <? if ( is_array( $this -> candidate['categories'] ) and count( $this -> candidate['categories'] ) ):?>
              <? foreach ( $this -> candidate['categories'] as $category ):?>
                <?= $category['name'];?><? if ( $category != end( $this -> candidate['categories'] ) ) echo ', ';?>
              <? endforeach;?>
            <? endif;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['mowie-w-nastepujacych-jezykach'] );?>:</label>
          <div class="col-12 col-sm-8">
            <? $languages_experience = \front\factory\Globelus::languages_experience();?>
            <? foreach ( $this -> candidate['languages'] as $language ):?>
              <p><?= $language['language'];?> - <?= $languages_experience[ $language['experience'] ];?></p>
            <? endforeach;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['szukam-pracy-w'] );?>:</label>
          <div class="col-12 col-sm-8">
            <? foreach ( $this -> candidate['countries'] as $country ):?>
              <?= $country;?><? if ( $country != end ( $this -> candidate['countries'] ) ):?>,<? endif;?>
            <? endforeach;?>
            <? if ( count( $this -> candidate['voivodeships'] ) ):?>
              <br/>
              <? foreach ( $this -> candidate['voivodeships'] as $voivodeship ):?>
                <?= $voivodeship;?><? if ( $voivodeship != end ( $this -> candidate['voivodeships'] ) ):?>,<? endif;?>
              <? endforeach;?>
            <? endif;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['moja-dostepnosc'] );?>:</label>
          <div class="col-12 col-sm-8">
            <? $availability_status = \front\factory\Globelus::availability_status();?>
            <?= $availability_status[ $this -> candidate['status_of_availability'] ];?>
            <? if ( $this -> candidate['status_of_availability'] == 2 ):?>
              <p><span class="text-danger">Jestem <?= $this -> candidate['sex'] ? 'dostępny' : 'dostępna';?> od:</span> <strong><?= $this -> candidate['date_of_availability'];?></strong></p>
            <? endif;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['posiadam-doswiadczenie-w-pracy-za-granica'] );?>:</label>
          <div class="col-12 col-sm-8">
            <?
              if ( $this -> candidate['experience_abroad'] == '1' )
                echo $lang['tak'];
              else if ( $this -> candidate['experience_abroad'] == '0' )
                echo $lang['nie'];
              else
                echo '-';
            ?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['potrzebuje-zakwaterowanie'] );?>:</label>
          <div class="col-12 col-sm-8">
            <?
              if ( $this -> candidate['accommodation'] == '1' )
                echo $lang['tak'];
              else if ( $this -> candidate['accommodation'] == '0' )
                echo $lang['nie'];
              else
                echo '-';
            ?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['mam-prawo-jazdy'] );?>:</label>
          <div class="col-12 col-sm-8">
            <?
              if ( $this -> candidate['driving_license'] == '1' )
                echo $lang['tak'];
              else if ( $this -> candidate['driving_license'] == '0' )
                echo $lang['nie'];
              else
                echo '-';
            ?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['mam-wlasny-samochod-do-dyspozycji'] );?>:</label>
          <div class="col-12 col-sm-8">
            <?
              if ( $this -> candidate['own_car'] == '1' )
                echo $lang['tak'];
              else if ( $this -> candidate['own_car'] == '0' )
                echo $lang['nie'];
              else
                echo '-';
            ?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['cv'] );?>:</label>
          <div class="col-12 col-sm-8">
            <? if ( file_exists( \front\factory\GlobelusCandidates::cv_url( $this -> candidate['id'] ) ) ):?><a href="/cv/<?= $this -> candidate['id'];?>/<?= \S::get_token();?>/"><?= $lang['zobacz-aktualne-cv'];?></a><? endif;?>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4"><?= ucfirst( $lang['dodatkowe-informacje'] );?>:</label>
          <div class="col-12 col-sm-8">
            <?= $this -> candidate['other_information'];?>
          </div>
        </div>
      </div>
    </div>
    <div class="row mb15">
      <div class="col-12 col-md-10">
        <div class="form-group row">
          <label class="col-12 col-sm-4">Notatka od Globelus.pl:</label>
          <div class="col-12 col-sm-8">
            <?= $this -> candidate['notes'];?>
          </div>
        </div>
      </div>
    </div>
    <? if ( $this -> prev_profile ):?>
      <a href="<?= $this -> prev_profile;?>" id="prev-cv" class="btn btn-system"><?= $lang['poprzedni-kandydat'];?></a>
    <? endif;?>
    <? if ( $this -> next_profile ):?>
      <a href="<?= $this -> next_profile;?>" id="next-cv" class="btn btn-system"><?= $lang['nastepny-kandydat'];?></a>
    <? endif;?>
  </div>
</div>
<? \front\factory\GlobelusCandidates::profile_visits_increase( $this -> candidate['id'], $this -> g_user['id'] );?>