Ejemplo n.º 1
0
  public static void show() {
    String username = session.get("username");
    if (username != null) {
      User user = User.getByUserName(username);
      Profile profile = Profile.find("user.id=?", user.id).first();

      render(profile);
    }
  }
Ejemplo n.º 2
0
  public static void toubiao() {
    String username = session.get("username");
    if (username != null) {
      User user = User.getByUserName(username);
      Profile profile = Profile.find("user.id=?", user.id).first();

      String payStyle = params.get("payStyle");
      String invoice = params.get("invoice");
      String comments = params.get("comments");
      String requestS = params.get("request");

      Request request = Request.findById(Long.valueOf(requestS));
      Toubiao toubiao = null;
      toubiao = Toubiao.find("request.id=? and profile.id=?", request.id, profile.id).first();
      if (toubiao == null) {
        toubiao = new Toubiao();
      }
      toubiao.profile = profile;
      toubiao.user = user;
      toubiao.request = request;
      toubiao.payStyle = payStyle;
      toubiao.invoice = invoice;
      toubiao.comments = comments;
      toubiao.again = false;
      toubiao.save();

      String price = "0";
      String price2 = "0";
      String price3 = "0";
      Baojia baojia = null;
      for (Specification spec : request.specifications) {
        price = params.get("price" + spec.id);
        price2 = params.get("price" + spec.id + "-2");
        price3 = params.get("price" + spec.id + "-3");
        baojia = Baojia.find("toubiao.id=? and specification.id=?", toubiao.id, spec.id).first();
        if (baojia == null) {
          baojia = new Baojia();
          baojia.toubiao = toubiao;
          baojia.specification = spec;
        }
        if (price != null && !"".equals(price) && !"0".equals(price))
          baojia.price = Double.valueOf(price);
        if (price2 != null && !"".equals(price2) && !"0".equals(price2))
          baojia.secondPrice = Double.valueOf(price2);
        if (price3 != null && !"".equals(price3) && !"0".equals(price3))
          baojia.thirdPrice = Double.valueOf(price3);
        baojia.save();

        if (!toubiao.baojias.contains(baojia)) {

          toubiao.baojias.add(baojia);
          toubiao.save();
        }
      }
    }
    redirect("/");
  }
Ejemplo n.º 3
0
  public static void newSpec() {
    List<Material> materials = Material.findAll();
    String username = session.get("username");
    if (username != null) {

      User user = User.getByUserName(username);
      if (user.role.name.equalsIgnoreCase("operator")) {
        materials = user.materials;
      }
    }
    render(materials);
  }
Ejemplo n.º 4
0
  public static void editSpec(Long id) {
    Specification spec = null;
    if (id != null) spec = Specification.findById(id);
    List<Material> materials = Material.findAll();
    String username = session.get("username");
    if (username != null) {

      User user = User.getByUserName(username);
      if (user.role.name.equalsIgnoreCase("operator")) {
        materials = user.materials;
      }
    }
    render(spec, materials);
  }