@Action( value = "confirm-ajax", results = { @Result( name = "success", location = "/WEB-INF/content/ajax/customer/customer-list-ajax.jsp") }) public String confirm() { customer = customerService.get(customer.getId()); customer.setConfirm(Confirm.approved); customerService.saveOrUpdate(customer); this.customerList = customerService.findAll(); return SUCCESS; }
@Action( value = "service-reg", results = {@Result(name = "success", type = "tiles", location = "/customers.tiles")}) public String list() { this.customerList = customerService.findAll(); this.carmarkList = carMarkService.findAll(); defectList = new LinkedList<Defect>(); session.put("defectList", defectList); costList = new LinkedList<Cost>(); session.put("costList", costList); return SUCCESS; }
@Action( value = "search-customer-ajax", results = { @Result( name = "success", location = "/WEB-INF/content/ajax/customer/customer-list-ajax.jsp") }) public String listAjax() { this.customerList = customerService.searchCustomer( firstDate, secondDate, searchCarFactory, searchCarMark, searchDate, searchCnumber); return SUCCESS; }
@Action( value = "customer-edit-ajax", results = { @Result( name = "success", location = "/WEB-INF/content/ajax/customer/customer-edit-ajax.jsp") }) public String customer_edit_ajax() { customer = customerService.get(customer.getId()); session.put("customer", customer); session.put("imageList", customer.getImageOfList()); session.put("defectList", customer.getDefectList()); session.put("costList", customer.getCostList()); this.carmarkList = carMarkService.getMarkForFactory(customer.getCarFactory().getId().toString()); return SUCCESS; }
public void prepare() throws Exception { if (customer != null && customer.getId() != null) { this.customer = customerService.get(customer.getId()); this.customerHash = customer.hashCode(); } }
@SuppressWarnings("unchecked") @Action( value = "customer-save", results = { @Result(name = "success", location = "/WEB-INF/content/ajax/customer/customer-result.jsp"), @Result(name = "input", location = "/WEB-INF/content/ajax/customer/customer-result.jsp") }) public String customersave() { boolean check = true; try { imageList = (List<Image>) session.get("imageList"); if (customer.getId() != null) { Customer c = (Customer) session.get("customer"); customer.setConfirm(c.getConfirm()); } customer.setImageOfList(imageList); if (customer.getCnumber().equals("")) { addFieldError("cnumber", Messages.getString("inputEmpty")); addFieldError("cnumberEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getColor().equals("")) { addFieldError("color", Messages.getString("inputEmpty")); addFieldError("colorEdit", Messages.getString("inputEmpty")); check = false; } else { if (customer.getColor().matches("[0-9]{4}[А-ЯӨҮ]{3}")) { addFieldError("color", Messages.getString("cnumber")); check = false; } } if (customer.getVinNumber().equals("")) { addFieldError("vinNumber", Messages.getString("inputEmpty")); addFieldError("vinNumberEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getOwnerName().equals("")) { addFieldError("ownerName", Messages.getString("inputEmpty")); addFieldError("ownerNameEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getOwnerAddress().equals("")) { addFieldError("ownerAddress", Messages.getString("inputEmpty")); addFieldError("ownerAddressEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getOwnerPhoneNumber().equals("")) { addFieldError("ownerPhoneNumberEdit", Messages.getString("inputEmpty")); addFieldError("ownerPhoneNumber", Messages.getString("inputEmpty")); check = false; } if (customer.getEstPoint().equals("")) { addFieldError("estPointEdit", Messages.getString("inputEmpty")); addFieldError("estPoint", Messages.getString("inputEmpty")); check = false; } if (customer.getMarketPrice().equals("")) { addFieldError("marketPrice", Messages.getString("inputEmpty")); addFieldError("marketPriceEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getConsumer().equals("")) { addFieldError("consumer", Messages.getString("inputEmpty")); check = false; } if (customer.getDefendant().equals("")) { addFieldError("defendant", Messages.getString("inputEmpty")); addFieldError("defendantEdit", Messages.getString("inputEmpty")); check = false; } if (customer.getAgentConsumer().equals("")) { addFieldError("agentConsumerEdit", Messages.getString("inputEmpty")); addFieldError("agentConsumer", Messages.getString("inputEmpty")); check = false; } if (customer.getEstimateMaterial().equals("")) { addFieldError("estimateMaterial", Messages.getString("inputEmpty")); addFieldError("estimateMaterialEdit", Messages.getString("inputEmpty")); } if (companyStr.trim().equals("")) { addFieldError("companyStrEdit", Messages.getString("inputEmpty")); addFieldError("companyStr", Messages.getString("inputEmpty")); check = false; } else { try { customer.setCompany(companyService.get(Long.parseLong(companyStr))); } catch (Exception e) { addFieldError("companyStrEdit", e.getMessage()); addFieldError("companyStr", e.getMessage()); check = false; } } if (!itypeStr.equals("")) { customer.setItype(InsuranceType.get(itypeStr)); } else { addFieldError("itypeStr", Messages.getString("inputEmpty")); addFieldError("itypeStrEdit", Messages.getString("inputEmpty")); check = false; } if (dateStr.equals("")) { addFieldError("dateStr", Messages.getString("inputEmpty")); addFieldError("dateStrEdit", Messages.getString("inputEmpty")); check = false; } else { customer.setDate(EstimaterStaticFunctions.strToDate(dateStr)); } if (factoryStr.equals("")) { addFieldError("factoryStr", Messages.getString("inputEmpty")); addFieldError("factoryStrEdit", Messages.getString("inputEmpty")); check = false; } else { try { customer.setCarFactory(carFactoryService.get(Long.parseLong(factoryStr))); } catch (Exception e) { addFieldError("factoryStr", e.getMessage()); addFieldError("factoryStrEdit", e.getMessage()); check = false; } } if (markStr.equals("")) { addFieldError("markStr", Messages.getString("inputEmpty")); addFieldError("markStrEdit", Messages.getString("inputEmpty")); check = false; } else { try { customer.setCarMark(carMarkService.get(Long.parseLong(markStr))); } catch (Exception e) { addFieldError("markStrEdit", e.getMessage()); addFieldError("markStr", e.getMessage()); check = false; } } if (customer.getFactoryDate().equals("")) { addFieldError("factoryDateEdit", Messages.getString("inputEmpty")); addFieldError("factoryDate", Messages.getString("inputEmpty")); check = false; } if (customer.getImportedDate().equals("")) { addFieldError("importedDate", Messages.getString("inputEmpty")); addFieldError("importedDateEdit", Messages.getString("inputEmpty")); check = false; } if (emp1Str.equals("")) { addFieldError("emp1Str", Messages.getString("inputEmpty")); addFieldError("emp1StrEdit", Messages.getString("inputEmpty")); check = false; } else { customer.setEmp1(employeeService.get(Long.parseLong(emp1Str))); } if (emp2Str.equals("")) { addFieldError("emp2Str", Messages.getString("inputEmpty")); addFieldError("emp2StrEdit", Messages.getString("inputEmpty")); check = false; } else { customer.setEmp2(employeeService.get(Long.parseLong(emp2Str))); } if (mainStr.equals("")) { addFieldError("mainStr", Messages.getString("inputEmpty")); addFieldError("mainStrEdit", Messages.getString("inputEmpty")); check = false; } else { customer.setMainEmp(employeeService.get(Long.parseLong(mainStr))); } if (carTypeStr.equals("")) { addFieldError("carTypeStr", Messages.getString("inputEmpty")); addFieldError("carTypeStrEdit", Messages.getString("inputEmpty")); check = false; } else { customer.setCarType(CarType.get(carTypeStr)); } if (!customer.getRegNumber().matches("[А-ЯӨҮ]{2}[0-9]{8}")) { addFieldError("regnumber", Messages.getString("cnumber")); addFieldError("regnumberEdit", Messages.getString("cnumber")); check = false; } if (check) { defectList = (List<Defect>) session.get("defectList"); for (Defect d : defectList) { defectService.saveOrUpdate(d); } customer.setDefectList(defectList); costList = (List<Cost>) session.get("costList"); for (Cost c : costList) { costService.saveOrUpdate(c); } customer.setCostList(costList); customerService.saveOrUpdate(customer); request.setAttribute("successMarkDialog", "true"); return SUCCESS; } return INPUT; } catch (Exception e) { addFieldError("mainStr", e.getMessage()); } return INPUT; }
@Action( value = "delete-pm-images", results = { @Result( name = "success", location = "/WEB-INF/content/ajax/customer/ajax-image-list-response.jsp"), @Result( name = "input", location = "/WEB-INF/content/ajax/customer/ajax-image-input-error-response.jsp"), @Result(name = "error", location = "/WEB-INF/content/ajax/customer/ajax-error-response.jsp") }) public String deleteImagesAction() { try { if (customer.getId() == null || customer.getId() == 0l) { addFieldError("id", Messages.getString("emptyError")); return INPUT; } String[] imageIds = request.getParameterValues("imageIds[]"); if (imageIds == null || imageIds.length <= 0) { addFieldError("imageIds", Messages.getString("emptyError")); return INPUT; } Customer cust = new Customer(); cust = customerService.get(customer.getId()); if (cust == null) { addFieldError("id", Messages.getString("wrongIdError")); return INPUT; } String filePathd = request.getSession().getServletContext().getRealPath("/") + "\\uploads"; String filePath = "c:/temp/"; for (int j = 0; j < imageIds.length; j++) { Long imageId = 0l; try { imageId = Long.parseLong(imageIds[j]); } catch (NumberFormatException e) { addFieldError("imageIds", Messages.getString("numberIdError")); return INPUT; } Image image = new Image(); image = imageService.get(imageId); if (image == null) { addFieldError("imageIds", Messages.getString("wrongIdError")); return INPUT; } for (int i = 0; i < cust.getImageOfList().size(); i++) { if (cust.getImageOfList().get(i).getId() == image.getId()) { cust.getImageOfList().remove(i); imageService.delete(image); FileUtils.deleteQuietly(new File(filePath + "\\" + image.getName())); FileUtils.deleteQuietly(new File(filePathd + "\\" + image.getName())); } } session.put("imageList", cust.getImageOfList()); } return SUCCESS; } catch (Exception e) { addFieldError("exception", Messages.getString("somethingWrong")); return ERROR; } }