Example #1
0
  @Check("isAdmin")
  public static void edit(String idSession) {
    Session sessions = Session.getSessionById(Long.parseLong(idSession));
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    String dateDebut = sdf.format(sessions.dateDepart);
    String dateFin = sdf.format(sessions.dateFin);

    List<ProduitType> listProduitTypes = Arrays.asList(ProduitType.values());

    Circuit tempCircuit = sessions.circuit;

    sessions.circuit = null;
    sessions.save();

    sessions = Session.getSessionById(Long.parseLong(idSession));
    sessions.circuit = tempCircuit;

    boolean isAvailableCircuit =
        Circuit.isAvailableCircuitByAgence(sessions.dateDepart, sessions.dateFin, sessions.agence);

    Agence agence = sessions.agence;
    render(
        "Sessions/add.html",
        sessions,
        dateDebut,
        dateFin,
        isAvailableCircuit,
        listProduitTypes,
        agence);
  }
Example #2
0
  @Check("isAdmin")
  public static void add(String startDate, String endDate, String idAgence) {
    String dateDebut = formatDateToDisplay(startDate);
    String dateFin = formatDateToDisplay(endDate);
    Agence agence = Agence.getAgenceById(Long.parseLong(idAgence));
    SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmm");
    try {
      Date sDate = dateFormat.parse(startDate);
      Date eDate = dateFormat.parse(endDate);
      List<Employe> listEmployes = Employe.getAvailableEmployes(sDate, eDate);
      List<Vehicule> listVehicules = Vehicule.getAvailableVehiculesByAgence(sDate, eDate, agence);
      boolean isAvailableCircuit = Circuit.isAvailableCircuitByAgence(sDate, eDate, agence);
      List<ProduitType> listProduitTypes = Arrays.asList(ProduitType.values());

      render(
          dateDebut,
          dateFin,
          listEmployes,
          listVehicules,
          isAvailableCircuit,
          agence,
          listProduitTypes);
    } catch (ParseException ex) {
      Logger.getLogger(Sessions.class.getName()).log(Level.SEVERE, null, ex);
    }
  }