Ejemplo n.º 1
0
  public static void useInvNumber(String invNumber) {
    Merchant merchant = MallUtil.getCurrentMerchant();
    String dir = merchant.getAbsolutePath() + "/invoiceCodes" + "/" + invNumber;
    try {
      Value val = (Value) SpringUtil.getRepositoryService().getFile(dir, Util.getRemoteUser());
      val.setStatus(40);
      val.save();
    } catch (FileNotFoundException fne) {

    }
  }
Ejemplo n.º 2
0
 public static String checkInvNumber(String invNumber) {
   Merchant merchant = MallUtil.getCurrentMerchant();
   String dir = merchant.getAbsolutePath() + "/invoiceCodes" + "/" + invNumber;
   try {
     Value val = (Value) SpringUtil.getRepositoryService().getFile(dir, Util.getRemoteUser());
     if (val.getStatus() == 40) {
       return "used";
     } else if (val.getStatus() == File.STATE_PUBLISHED) {
       return "ok";
     } else {
       return "notprinted";
     }
   } catch (FileNotFoundException fne) {
     Order order = getOrder(invNumber);
     if (order != null) {
       return "used";
     } else {
       return "ok";
     }
   }
 }
  @Override
  public boolean ServerAction(Container container, Map<String, String> request) throws UIException {
    if (container.getName().equals("title")
        || container.getName().equals("image")
        || container.getName().equals("img")) {

      return false;
    }

    if (container.getName().startsWith("sp")) {
      String path = container.getAttribute("path");
      if (StringUtil.isNotEmpty(path) && !path.equalsIgnoreCase("null")) {
        Product p =
            (Product)
                SpringUtil.getRepositoryService()
                    .getFile(container.getAttribute("path"), Util.getRemoteUser());
        setProduct(p);
      }
      return true;
    }

    if (container.getName().startsWith("star")) {
      int index = Integer.parseInt(container.getName().replace("star", "")) + 1;
      Product p =
          (Product)
              SpringUtil.getRepositoryService().getFile(getAttribute("path"), Util.getRemoteUser());
      for (int i = 0; i < index; i++) {
        getChild("star" + i).setStyle("background", "green");
      }

      String u = Util.getRemoteUser();
      if (!StringUtil.isNotEmpty(u)) {
        u = "anonymous";
      }
      Directory votes = (Directory) p.getFile("votes");
      if (votes == null) {
        votes = p.createFile("votes", Directory.class);
      }

      String cur = votes.getProperty(u);

      if (cur == null) {
        cur = "0";
      }
      try {
        Integer.parseInt(cur);

      } catch (Exception e) {
        cur = "0";
      }

      votes.setProperty(u, (Integer.parseInt(cur) + index) + "");

      p.save();
      return true;
    }

    if (container.getName().startsWith("tn")) {
      for (Container c : getChildren()) {
        if (c.getName().startsWith("tn")) {
          c.setStyleClass("uibutton");
        }
      }
      container.setStyleClass("uibutton uibutton_active");
      getChild("image").setAttribute("src", container.getAttribute("src"));
      return true;
    }

    if (container.getName().equals("merchant")) {
      Merchant m = MallUtil.getMerchant(container.getAttribute("merchant"));
      // EXMerchantInfo info = new EXMerchantInfo("");
      EXMerchantCardV2 info = new EXMerchantCardV2("sd", m);
      EXPanel panel = new EXPanel("mm", m.getCompanyName());
      panel.setBody(info);
      // info.setMerchant(m);
      container
          .getAncestorOfType(PopupContainer.class)
          .addPopup(panel.setStyle("z-index", "3000").setStyle("width", "704px"));
      return true;
    }

    if (container.getName().equals("thumbUp")) {
      Product p =
          (Product)
              SpringUtil.getRepositoryService().getFile(getAttribute("path"), Util.getRemoteUser());
      p.thumbUp();
      p.save();
      return true;
    }

    if (container.getName().equals("thumbDown")) {
      Product p =
          (Product)
              SpringUtil.getRepositoryService().getFile(getAttribute("path"), Util.getRemoteUser());
      p.thumbDown();
      p.save();
      return true;
    }

    EXInput in = getDescendentOfType(EXInput.class);
    int value = Integer.parseInt(in.getValue().toString());
    if (container.getName().equals("addQty")) {
      in.setValue((value + 1) + "");
    } else if (container.getName().equals("delQty")) {
      if (value > 0) {
        in.setValue((value - 1) + "");
      }
    } else if (container.getName().equals("addToCart")) {
      if (container.getAncestorOfType(EXMall.class) != null) {
        Product p =
            (Product)
                SpringUtil.getRepositoryService()
                    .getFile(getAttribute("path"), Util.getRemoteUser());
        EXMiniCarts carts = getRoot().getDescendentOfType(EXMiniCarts.class);
        if (carts.getChildren().size() == 0) {
          carts.addChild(
              new EXContainer("totalll", "h4")
                  .addClass("ui-widget-header")
                  .setStyle("margin", "0")
                  .setStyle("width", "100%")
                  .setStyle("text-align", "center"));
        }
        EXMiniCart cart =
            getRoot().getDescendentOfType(EXMiniCarts.class).getMiniCart(p.getProvidedBy());
        if (!cart.getTemplateLocation().endsWith("EXMinicartNG.xhtml")) {
          cart.setTemplateLocation("templates/ng/EXMinicartNG.xhtml");
          cart.getParent().setStyle("float", "right").setStyle("margin-top", "12px");
          cart.addChild(new EXContainer("images", "div").setStyle("height", "20px"));
          cart.removeClass("cart-widget")
              .setStyle("margin", "0")
              .setStyle("padding", "0")
              .setStyle("margin-top", "0");
          cart.addChild(
              new EXContainer("checkout", "a")
                  .addEvent(new CartDetailEvent(), Event.CLICK)
                  .setAttribute("href", "#")
                  .setText("<img src=\"blueprint/images/checkout.png\"></img>"));
        }
        CartItem item = cart.getItem(p.getAbsolutePath());
        if (item == null) {
          cart.getChild("images")
              .addChild(
                  new EXContainer("img", "img")
                      .setStyle("cursor", "pointer")
                      .setAttribute("path", p.getAbsolutePath())
                      .addEvent(this, CLICK)
                      .setStyle("margin", "4px 4px 0px 4px")
                      .setStyle("width", "30px")
                      .setStyle("height", "30px")
                      .setAttribute("src", p.getImageUrl("")));
        }
        CartItem citem = cart.addToCart(p, value, container);
      } else {
        Product p =
            (Product)
                SpringUtil.getRepositoryService()
                    .getFile(getAttribute("path"), Util.getRemoteUser());
        getRoot().getDescendentOfType(EXMiniCart.class).addToCart(p, 1, container);
      }
    } else {
      Product p =
          (Product)
              SpringUtil.getRepositoryService().getFile(getAttribute("path"), Util.getRemoteUser());
      try {
        MallUtil.getCurrentUser().addToFavorite(p.getAbsolutePath());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return true;
  }