/**
   * Lists all active jobs where user can make an offer.
   *
   * @param model Model of page
   * @param principal Current user details
   * @return view name "jobs" as String
   */
  @RequestMapping("/jobs")
  public String listJobs(Model model, Principal principal) {
    System.out.println("jobs");
    List<Job> jobs = jobDao.getActiveJobs();
    model.addAttribute("jobs", jobs);
    User user = null;
    List<Offer> offers = null;
    if (principal != null) {
      user = userDao.findByEmail(principal.getName());
      offers = offerDao.getActiveOffersByUser(user);
      for (Job job : jobs) {
        Long jobId = job.getId();
        if (job.getUser().getId().equals(user.getId())) {
          job.setShow(false);
        } else {
          for (Offer offer : offers) {
            if (offer.getJob().getId().equals(jobId)) {
              job.setShow(false);
            }
          }
        }
      }
      model.addAttribute("user", user);
      model.addAttribute("count", jobDao.getCounts(user));
    }

    return "jobs";
  }
 /**
  * Opens page where user can create new job
  *
  * @param model Model of page
  * @param principal Current user details
  * @return view name "createjob" as String
  */
 @RequestMapping("/createJob")
 public String createJob(Model model, Principal principal) {
   System.out.println("createjob");
   User user = userDao.findByEmail(principal.getName());
   model.addAttribute("user", user);
   Job job = new Job();
   job.setUser(user);
   model.addAttribute("job", job);
   model.addAttribute("count", jobDao.getCounts(user));
   return "createjob";
 }