r104 - in trunk/chorem-web/src/main: java/org/chorem/bonzoms/action resources resources/i18n webapp/WEB-INF/jsp/billy webapp/WEB-INF/jsp/bonzoms
Author: vbriand Date: 2011-04-22 12:23:48 +0200 (Fri, 22 Apr 2011) New Revision: 104 Url: http://chorem.org/repositories/revision/chorem/104 Log: The company details can now be modified Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties trunk/chorem-web/src/main/resources/struts.xml trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/addQuotation.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companyDetails.jsp Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java 2011-04-22 10:23:48 UTC (rev 104) @@ -88,11 +88,11 @@ setAddress(contactDetails.getValue()); } else if (contactDetails.getName().equals( CONTACT_DETAILS_PHONE + " of company \"" + - name + "\"")) { + company.getName() + "\"")) { setPhoneNb(contactDetails.getValue()); } else if (contactDetails.getName().equals( CONTACT_DETAILS_WEBSITE + " of company \"" + - name + "\"")) { + company.getName() + "\"")) { setWebsite(contactDetails.getValue()); } } @@ -107,6 +107,74 @@ return result; } + /** + * Modifies the company information + * + * @return SUCCESS if the modification was successful, + * ERROR otherwise + */ + public String modify() { + String result = SUCCESS; + ChoremProxy proxy = getChoremProxy(); + Company company; + + company = proxy.restore(Company.class, companyId); + company.setType(type); + proxy.store(company); + + List<ContactDetails> contactDetailsList = ChoremProxy. + getContactDetails(companyId); + boolean newPhone = true, newWebsite = true; + + //Modification of existing contact details + for (ContactDetails contactDetails : contactDetailsList) { + if (contactDetails.getName().equals( + CONTACT_DETAILS_POSTAL_ADDRESS + + " of company \"" + company.getName() + "\"")) { + contactDetails.setValue(address); + } else if (contactDetails.getName().equals( + CONTACT_DETAILS_PHONE + " of company \"" + + company.getName() + "\"")) { + contactDetails.setValue(phoneNb); + newPhone = false; + } else if (contactDetails.getName().equals( + CONTACT_DETAILS_WEBSITE + " of company \"" + + company.getName() + "\"")) { + contactDetails.setValue(website); + newWebsite = false; + } + proxy.store(contactDetails); + } + + //Phone number added + if (newPhone && !phoneNb.isEmpty()) { + ContactDetailsImpl newContactDetails = new ContactDetailsImpl(); + + newContactDetails = new ContactDetailsImpl(); + newContactDetails.setName(CONTACT_DETAILS_PHONE + + " of company \"" + company.getName() + "\""); + newContactDetails.setType(CONTACT_DETAILS_PHONE); + newContactDetails.setValue(phoneNb); + newContactDetails.setTarget(company.getWikittyId()); + proxy.store(newContactDetails); + System.out.println(newContactDetails); + } + + //Website added + if (newWebsite && !website.isEmpty()) { + ContactDetailsImpl newContactDetails = new ContactDetailsImpl(); + + newContactDetails = new ContactDetailsImpl(); + newContactDetails.setName(CONTACT_DETAILS_WEBSITE + + " of company \"" + company.getName() + "\""); + newContactDetails.setType(CONTACT_DETAILS_WEBSITE); + newContactDetails.setValue(website); + newContactDetails.setTarget(company.getWikittyId()); + proxy.store(newContactDetails); + } + return result; + } + protected String name; protected String type; protected String addressLine1; Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-04-22 10:23:48 UTC (rev 104) @@ -137,3 +137,4 @@ chorem.gepeto.task.price.wrongFormat=The price must be a positive integer or floating point number (the decimal mark may be either a dot or a comma) chorem.gepeto.tasksList= chorem.home=Home +chorem.misc.modify=Modify Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-04-22 10:23:48 UTC (rev 104) @@ -54,7 +54,7 @@ chorem.bonzoms.employmentContract.allFieldsRequired= chorem.bonzoms.employmentContract.beginDate=Date de d\u00E9but chorem.bonzoms.employmentContract.description=Description -chorem.bonzoms.employmentContract.endDate=Date de fin +chorem.bonzoms.employmentContract.endDate=Date de fin (opt.) chorem.bonzoms.employmentContract.salary=Salaire chorem.bonzoms.employmentContract.salary.wrongFormat=Le salaire doit \u00EAtre un entier positif ou un nombre \u00E0 virgule flottante positif (le s\u00E9parateur d\u00E9cimal peut \u00EAtre un point ou une virgule) chorem.bonzoms.employmentContract.type=Type @@ -142,3 +142,4 @@ chorem.gepeto.task.price.wrongFormat=Le prix doit \u00EAtre un entier positif ou un nombre \u00E0 virgule flottante positif (le s\u00E9parateur d\u00E9cimal peut \u00EAtre un point ou une virgule) chorem.gepeto.tasksList= chorem.home=Accueil +chorem.misc.modify=Modifier Modified: trunk/chorem-web/src/main/resources/struts.xml =================================================================== --- trunk/chorem-web/src/main/resources/struts.xml 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/resources/struts.xml 2011-04-22 10:23:48 UTC (rev 104) @@ -54,6 +54,13 @@ <result name="error">/WEB-INF/jsp/bonzoms/addEmploymentContract.jsp</result> <result type="redirectAction">home</result> </action> + <action name="modifyCompany" class="org.chorem.bonzoms.action.CompanyAction" method="modify"> + <result type="redirectAction"> + <param name="actionName">companyDetails</param> + <param name="namespace">/bonzoms</param> + <param name="companyId">${companyId}</param> + </result> + </action> </package> <package name="gepeto" namespace="/gepeto" extends="struts-default"> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/addQuotation.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/addQuotation.jsp 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/addQuotation.jsp 2011-04-22 10:23:48 UTC (rev 104) @@ -30,11 +30,11 @@ <br /> <s:textarea key="chorem.billy.quotation.description" name="description" cols="50" rows="10" labelposition="top" labelSeparator=": " /> <br /> - <s:textfield key="chorem.billy.quotation.amount" name="amount" labelSeparator=": " /> + <s:textfield key="chorem.billy.quotation.amount" name="amount" labelSeparator=": " size="6" /> <br /> - <s:textfield key="chorem.billy.quotation.vta" name="vta" labelSeparator=": " /> + <s:textfield key="chorem.billy.quotation.vta" name="vta" labelSeparator=": " size="2" />% <br /> - <s:textfield key="chorem.billy.quotation.postedDate" name="postedDate" labelSeparator=": " /> + <s:textfield key="chorem.billy.quotation.postedDate" name="postedDate" labelSeparator=": " size="7" /> <br /> <label for="supplierId" class="label"><s:text name="chorem.billy.quotation.supplier" />: </label> <select name="supplierId" id="supplierId"> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companyDetails.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companyDetails.jsp 2011-04-22 08:40:03 UTC (rev 103) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companyDetails.jsp 2011-04-22 10:23:48 UTC (rev 104) @@ -21,16 +21,24 @@ </s:text> </h2> <s:actionerror /> - <s:textfield key="chorem.bonzoms.company.type" name="type" labelSeparator=": " readonly="true" /> + <s:url action="modifyCompany" var="modifyCompany"> + <s:param name="companyId"><%= CompanyAction.getAction().getCompanyId() %></s:param> + </s:url> + <form action="${modifyCompany}" method="post"> + <s:textfield key="chorem.bonzoms.company.type" name="type" labelSeparator=": " /> + <br /> + <br /> + <s:textarea key="chorem.bonzoms.company.address" name="address" cols="30" rows="3" labelposition="top" /> + <br /> + <s:textfield key="chorem.bonzoms.company.phoneNb" name="phoneNb" labelSeparator=": " /> + <br /> + <s:textfield key="chorem.bonzoms.company.website" name="website" labelSeparator=": " /> + <br /> + <br /> + <s:submit key="chorem.misc.modify" name="modify" /> + </form> <br /> <br /> - <s:textarea key="chorem.bonzoms.company.address" name="address" readonly="true" cols="50" rows="3" labelposition="top" /> - <br /> - <s:textfield key="chorem.bonzoms.company.phoneNb" name="phoneNb" labelSeparator=": " readonly="true" /> - <br /> - <s:textfield key="chorem.bonzoms.company.website" name="website" labelSeparator=": " readonly="true" /> - <br /> - <br /> <s:text name="chorem.bonzoms.company.employees" /> <br /> <br />
participants (1)
-
vbriand@users.chorem.org