Author: vbriand Date: 2011-04-07 18:09:06 +0200 (Thu, 07 Apr 2011) New Revision: 63 Url: http://chorem.org/repositories/revision/chorem/63 Log: The project orders are visible on the quotation page and the quotations with a project order are visible on the project's page Modified: trunk/chorem-web/src/main/java/org/chorem/billy/action/QuotationAction.java trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.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/quotationDetails.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectDetails.jsp Modified: trunk/chorem-web/src/main/java/org/chorem/billy/action/QuotationAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/billy/action/QuotationAction.java 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/java/org/chorem/billy/action/QuotationAction.java 2011-04-07 16:09:06 UTC (rev 63) @@ -9,8 +9,11 @@ import org.chorem.ChoremProxy; import org.chorem.action.BaseAction; import org.chorem.entities.Project; +import org.chorem.entities.ProjectOrder; import org.chorem.entities.Quotation; import org.chorem.entities.QuotationImpl; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.Search; import com.opensymphony.xwork2.ActionContext; @@ -121,6 +124,21 @@ protected String quotationId; /** + * Returns the project order linked with the quotation (if it exists) + * + * @return the project order if it exists + * @return null if it doesn't exist + */ + public ProjectOrder getProjectOrder() { + ChoremProxy proxy = getChoremProxy(); + Search search = Search.query(); + Criteria criteria = search.eq(ProjectOrder.FQ_FIELD_PROJECTORDER_QUOTATION, + quotationId).criteria(); + ProjectOrder result = proxy.findByCriteria(ProjectOrder.class, criteria); + return result; + } + + /** * Stores the new quotation through the proxy * * @return true if the quotation has been stored properly Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java 2011-04-07 16:09:06 UTC (rev 63) @@ -1,5 +1,6 @@ package org.chorem.gepeto.action; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -9,6 +10,7 @@ import org.chorem.action.BaseAction; import org.chorem.entities.Project; import org.chorem.entities.ProjectImpl; +import org.chorem.entities.ProjectOrder; import org.chorem.entities.Quotation; import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.PagedResult; @@ -129,7 +131,8 @@ public List<Project> getAllProjects() { ChoremProxy proxy = getChoremProxy(); Search search = Search.query(); - Criteria criteria = search.isNotNull(Project.FQ_FIELD_PROJECT_NAME).criteria(); + Criteria criteria = search.isNotNull(Project.FQ_FIELD_PROJECT_NAME). + criteria(); PagedResult<Project> result = proxy.findAllByCriteria(Project.class, criteria); List<Project> projects = result.getAll(); @@ -153,6 +156,39 @@ } /** + * Gets the quotations with a project order attached with them + * + * @return the quotations with a project order + */ + public List<Quotation> getAttachedQuotationsWithProjectOrder() { + ChoremProxy proxy = getChoremProxy(); + Search search = Search.query(); + Criteria criteria = search.exteq(ProjectOrder.EXT_PROJECTORDER). + associated(ProjectOrder.FQ_FIELD_PROJECTORDER_QUOTATION). + eq(Quotation.FQ_FIELD_QUOTATION_PROJECT, projectId).criteria(); + PagedResult<ProjectOrder> result = proxy.findAllByCriteria(ProjectOrder.class, + criteria); + List<ProjectOrder> projectOrders = result.getAll(); + List<Quotation> quotations = new ArrayList<Quotation>(); + + for (ProjectOrder projectOrder : projectOrders) { + quotations.add(proxy.restore(Quotation.class, + projectOrder.getQuotation())); + } + return quotations; + } + + /** + * Gets the quotations without a project order attached with them + * + * @return the quotations without a project order + */ + public List<Quotation> getAttachedQuotationsWithoutProjectOrder() { + //TODO: implement + return null; + } + + /** * @return the name */ public String getName() { Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java 2011-04-07 16:09:06 UTC (rev 63) @@ -73,30 +73,6 @@ return result; } - public String input() { - String result = INPUT; - ChoremProxy proxy = getChoremProxy(); - - try { - if (quotationId == null) { - result = ERROR; - } else { - UUID.fromString(quotationId); - - Quotation quotation = proxy.restore(Quotation.class, quotationId); - - if (quotation == null) { - result = ERROR; - } else { - quotationReference = quotation.getReference(); - } - } - } catch (IllegalArgumentException e) { - result = ERROR; - } - return result; - } - protected String type; protected String description; protected String beginDate; 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-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-04-07 16:09:06 UTC (rev 63) @@ -9,6 +9,12 @@ chorem.billy.quotation.create.error=An error occurred while creating your new quotation, please try again. If the problem persists, please contact an administrator chorem.billy.quotation.description=Description chorem.billy.quotation.postedDate=Posted date +chorem.billy.quotation.projectOrder= +chorem.billy.quotation.projectOrder.beginDate= +chorem.billy.quotation.projectOrder.company= +chorem.billy.quotation.projectOrder.endDate= +chorem.billy.quotation.projectOrder.estimatedEndDate= +chorem.billy.quotation.projectOrder.type= chorem.billy.quotation.reference=Reference chorem.billy.quotation.vta=VTA chorem.billy.quotationDetails.title= @@ -91,7 +97,8 @@ chorem.gepeto.project.name=Project''s name chorem.gepeto.project.name.required=You must enter the project''s name chorem.gepeto.projectDetails.quotation=Quotation of {0} (ref. {1}) -chorem.gepeto.projectDetails.quotations=Project''s quotations +chorem.gepeto.projectDetails.quotationWithProjectOrder=Project''s quotation with project order +chorem.gepeto.projectDetails.quotationsWithoutProjectOrder=Project''s quotations without project order chorem.gepeto.projectDetails.title=Details of project "{0}" chorem.gepeto.projectOrder=Project order chorem.gepeto.projectOrder.add=Add a new project order 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-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-04-07 16:09:06 UTC (rev 63) @@ -2,13 +2,18 @@ chorem.billy.home=Accueil chorem.billy.quotation=Devis \#{0} chorem.billy.quotation.add=Ajouter un nouveau devis -chorem.billy.quotation.addProjectOrder= +chorem.billy.quotation.addProjectOrder=Cr\u00E9er un contrat pour ce devis chorem.billy.quotation.addToProject=Ajouter un nouveau devis au projet "{0}" chorem.billy.quotation.amount=Montant chorem.billy.quotation.backToProjectDetails=Retourner sur le projet chorem.billy.quotation.create.error=Une erreur s''est produite lors de la cr\u00E9ation de votre nouveau devis, merci d''essayer \u00E0 nouveau. Si le probl\u00E8me se reproduit, merci de contacter un administrateur chorem.billy.quotation.description=Description chorem.billy.quotation.postedDate=Date de d\u00E9p\u00F4t +chorem.billy.quotation.projectOrder=Contrat r\u00E9alis\u00E9 sur la base de ce devis +chorem.billy.quotation.projectOrder.beginDate=Date de d\u00E9but \: {0} +chorem.billy.quotation.projectOrder.company=Soci\u00E9t\u00E9 \: {0} +chorem.billy.quotation.projectOrder.endDate=Date de fin \: {0} +chorem.billy.quotation.projectOrder.type=Type \: {0} chorem.billy.quotation.reference=R\u00E9f\u00E9rence chorem.billy.quotation.vta=TVA chorem.billy.quotationDetails.title= @@ -87,7 +92,8 @@ chorem.gepeto.project.name=Nom du projet chorem.gepeto.project.name.required=Vous devez renseigner un nom pour le projet chorem.gepeto.projectDetails.quotation=Devis du {0} (r\u00E9f. {1}) -chorem.gepeto.projectDetails.quotations=Devis du projet +chorem.gepeto.projectDetails.quotationWithProjectOrder=Devis du projet avec un contrat +chorem.gepeto.projectDetails.quotationsWithoutProjectOrder=Devis du projet sans contrat chorem.gepeto.projectDetails.title=D\u00E9tails du projet "{0}" chorem.gepeto.projectOrder=Contrat de commande d''un projet chorem.gepeto.projectOrder.add=Ajouter le contrat d''un projet Modified: trunk/chorem-web/src/main/resources/struts.xml =================================================================== --- trunk/chorem-web/src/main/resources/struts.xml 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/resources/struts.xml 2011-04-07 16:09:06 UTC (rev 63) @@ -82,7 +82,7 @@ </action> <action name="addProjectOrder" class="org.chorem.gepeto.action.ProjectOrderAction" method="add"> <result name="input">/WEB-INF/jsp/gepeto/addProjectOrder.jsp</result> - <result name="error" type="redirectAction">home</result> + <result name="error">/WEB-INF/jsp/gepeto/addProjectOrder.jsp</result> <result type="redirectAction">home</result> </action> <action name="getProjectsByYear" class="org.chorem.gepeto.action.ProjectAction"> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/quotationDetails.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/quotationDetails.jsp 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/billy/quotationDetails.jsp 2011-04-07 16:09:06 UTC (rev 63) @@ -1,5 +1,6 @@ <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@page import="org.chorem.billy.action.QuotationAction" %> +<%@page import="org.chorem.entities.ProjectOrder" %> <%@taglib prefix="s" uri="/struts-tags" %> <html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" @@ -35,7 +36,33 @@ <s:url namespace="/gepeto" action="projectDetails" var="projectDetails"> <s:param name="projectId"><%= QuotationAction.getAction().getProjectId() %></s:param> </s:url> - <a href="${addProjectOrder}"><s:text name="chorem.billy.quotation.addProjectOrder" /></a> + <% + ProjectOrder projectOrder = QuotationAction.getAction().getProjectOrder(); + + if (projectOrder != null) { + %> + <s:text name="chorem.billy.quotation.projectOrder" /> + <br /> + <s:text name="chorem.billy.quotation.projectOrder.beginDate"> + <s:param><%= projectOrder.getBeginDate() %></s:param> + </s:text> + <br /> + <s:text name="chorem.billy.quotation.projectOrder.endDate"> + <s:param><%= projectOrder.getEndDate() %></s:param> + </s:text> + <br /> + <s:text name="chorem.billy.quotation.projectOrder.type"> + <s:param><%= projectOrder.getType() %></s:param> + </s:text> + <br /> + <s:text name="chorem.billy.quotation.projectOrder.company"> + <s:param><%= projectOrder.getCompany() %></s:param> + </s:text> + <br /> + <% } else { %> + <a href="${addProjectOrder}"><s:text name="chorem.billy.quotation.addProjectOrder" /></a> + <br /> + <% } %> <br /> <a href="${projectDetails}"><s:text name="chorem.billy.quotation.backToProjectDetails" /></a> </p> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectDetails.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectDetails.jsp 2011-04-07 09:42:30 UTC (rev 62) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectDetails.jsp 2011-04-07 16:09:06 UTC (rev 63) @@ -30,10 +30,33 @@ <a href="${addQuotation}"><s:text name="chorem.billy.quotation.add" /></a> </p> <p> - <s:text name="chorem.gepeto.projectDetails.quotations" /> + <s:text name="chorem.gepeto.projectDetails.quotationWithProjectOrder" /> <br /> <br /> + <% + List<Quotation> quotationsProjectOrder = ProjectAction.getAction().getAttachedQuotationsWithProjectOrder(); + + for (Quotation quotation : quotationsProjectOrder) { + %> + <s:url namespace="/billy" action="quotationDetails" var="quotationDetails"> + <s:param name="quotationId"><%= quotation.getWikittyId() %></s:param> + </s:url> + <s:text name="chorem.gepeto.projectDetails.quotation"> + <s:param> + <%= quotation.getPostedDate() %> + </s:param> + <s:param> + <a href="${quotationDetails}"><%= quotation.getReference() %></a> + </s:param> + </s:text> + <br /> + <% } %> + <br /> + <s:text name="chorem.gepeto.projectDetails.quotationsWithoutProjectOrder" /> + <br /> + <br /> <% + //TODO: change to getAttachedQuotationsWithoutProjectOrder when it will be implemented List<Quotation> quotations = ProjectAction.getAction().getAttachedQuotations(); for (Quotation quotation : quotations) {