<?php
namespace admin\controls;
class GlobelusCandidates
{
  public static function switch_account_type() {
    if ( \admin\factory\GlobelusCandidates::switch_account_type( \S::get( 'id' ) ) )
      \S::alert( 'Typ konta został zmieniony.' );

    header( 'Location: /admin/globelus_candidates/main_view/' );
    exit;
  }

  public static function candidate_visits()
  {
    return \admin\view\GlobelusCandidates::candidate_visits( \S::get( 'id' ) );
  }

  public static function candidate_highlight()
  {
    if ( \admin\factory\GlobelusCandidates::candidate_highlight( \S::get( 'id' ) ) )
      \S::alert( 'Profil kandydata został wyróżniony.' );

    header( 'Location: /admin/globelus_candidates/candidate_preview/id=' . \S::get( 'id' ) );
    exit;
  }

  public static function candidate_preview()
  {
    return \Tpl::view( 'globelus-candidates/candidate-preview', [
      'candidate' => \admin\factory\GlobelusCandidates::candidate_details( \S::get( 'id' ) ),
      'categories' => \front\factory\GlobelusAdverts::categories(),
      'positions' => \front\factory\Globelus::get_positions_list()
    ] );
  }

  public static function candidate_delete()
  {
    if ( \admin\factory\GlobelusCandidates::candidate_delete( \S::get( 'id' ) ) )
      \S::alert( 'Profil kandydata został usunięty.' );

    header( 'Location: /admin/globelus_candidates/main_view/' );
    exit;
  }

  public static function main_view()
  {
    return \admin\view\GlobelusCandidates::main_view();
  }

  public static function uregistered_main_view()
  {
    return \admin\view\GlobelusCandidates::uregistered_main_view();
  }
}
