AdminBean adminBean = getAdminBean(request);
User user = adminBean.getUser();
OrderMaintActionForm form = (OrderMaintActionForm) actionForm;
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
OrderHeader orderHeader = (OrderHeader) em.find(OrderHeader.class, Format.getLong(form.getOrderHeaderId()));
ActionMessages errors = validateShipping(form);
if (errors.size() != 0) {
saveMessages(request, errors);
initOrder(form, orderHeader, null, null, null, request);
return actionMapping.findForward("error");
}
orderHeader.setShippingTotal(Format.getFloatObj(form.getShippingQuoteTotal()));
orderHeader.setShippingValidUntil(Format.getDate(form.getShippingValidUntil()));
OrderEngine orderEngine = new OrderEngine(orderHeader, null);
try {
orderEngine.sendShippingQuoteEmail(this.getServlet().getServletContext());
OrderTracking orderTracking = new OrderTracking();
orderTracking.setOrderTrackingCode("");
orderTracking.setOrderTrackingMessage("Shipping qoute sent");
orderTracking.setOrderTrackingInternal(String.valueOf(Constants.VALUE_NO));
orderTracking.setRecUpdateBy(user.getUserId());
orderTracking.setRecUpdateDatetime(new Date());
orderTracking.setRecCreateBy(user.getUserId());
orderTracking.setRecCreateDatetime(new Date());
orderTracking.setOrderHeader(orderHeader);
em.persist(orderTracking);
orderHeader.getOrderTrackings().add(orderTracking);
}
catch (Exception e) {
logger.error("Unable to send mail", e);
initOrder(form, orderHeader, null, null, null, request);
errors.add("sendShippingQuote", new ActionMessage("content.error.mail.send"));