Author: deepaknigam
Date: Sat Jun 22 12:06:43 2019 New Revision: 1861853 URL: http://svn.apache.org/viewvc?rev=1861853&view=rev Log: Implemented: The feature where a user will be able to add different types of content(image, document, URL, etc.) to an order. (OFBIZ-7257) Here is an implementation plan for the proposed solution. Order Attachment Flow: 1) Show 'Attachments' instead of 'Image' on the order view screen. 2) If there are any attachments associated with the order, then their information will be displayed in the form of a button(Content link) else 'No Attachment' label should be shown. 3) If no attachments are there, then along with the label, a button(Add Attachment) will be displayed. On clicking the Add Attachment button, a user will be redirected to a page where he/she can add different types of content(image, document, URL, etc.) to the order. Order Attachment Modeling: Used OrderContent as the entity to store the content and order association. Created OrderContentType data for an image and document for starters. Thanks Avnindra Sharma for reporting the original issue, Devanshu Vyas for providing the patch and Jacques for review and suggestions. Added: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy (with props) ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl (with props) Modified: ofbiz/ofbiz-framework/trunk/applications/order/data/OrderTypeData.xml ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml ofbiz/ofbiz-framework/trunk/applications/order/template/order/OrderInfo.ftl ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml ofbiz/ofbiz-framework/trunk/framework/common/config/CommonUiLabels.xml Modified: ofbiz/ofbiz-framework/trunk/applications/order/data/OrderTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/data/OrderTypeData.xml?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/data/OrderTypeData.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/data/OrderTypeData.xml Sat Jun 22 12:06:43 2019 @@ -21,6 +21,7 @@ under the License. <entity-engine-xml> <!-- Content Types --> <OrderContentType description="Image" hasTable="N" orderContentTypeId="IMAGE_URL"/> + <OrderContentType description="Document" hasTable="N" orderContentTypeId="DOCUMENT"/> <EmailTemplateSetting emailTemplateSettingId="CUST_REQ_ACCEPTED" Added: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy?rev=1861853&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy (added) +++ ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy Sat Jun 22 12:06:43 2019 @@ -0,0 +1,8 @@ +import org.apache.ofbiz.base.util.UtilDateTime; + +if (parameters.orderId) { + orderItems = from("OrderItem").where("orderId", parameters.orderId).queryList(); + context.orderItems = orderItems; + context.orderContentTypes = from("OrderContentType").queryList(); + context.fromDate = UtilDateTime.nowTimestamp(); +} Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/order/groovyScripts/order/AddOrderAttachments.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services.xml Sat Jun 22 12:06:43 2019 @@ -1354,4 +1354,12 @@ under the License. <attribute name="allocatedQuantityMap" type="Map" mode="IN" string-map-prefix="aqm_"/> <attribute name="rowSubmitMap" type="Map" mode="IN" string-map-prefix="rsm_"/> </service> + + <service name="uploadOrderContentFile" engine="group" transaction-timeout="300"> + <description>Upload and attach a file to an order</description> + <group> + <invoke name="createContentFromUploadedFile" result-to-context="true"/> + <invoke name="createOrderContent"/> + </group> + </service> </services> Added: ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl?rev=1861853&view=auto ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl (added) +++ ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl Sat Jun 22 12:06:43 2019 @@ -0,0 +1,43 @@ +<div class="screenlet add-order-attachments"> + <div class="screenlet-title-bar"> + Add Order Attachments + </div> + <div class="screenlet-body"> + <form name="AddOrderAttachmentsForm" method="post" action="<@ofbizUrl>addOrderAttachments</@ofbizUrl>" enctype="multipart/form-data"> + <input type="hidden" name="orderId" value="${parameters.orderId!}"> + <input type="hidden" name="fromDate" value="${fromDate!}"> + <div> + ${uiLabelMap.OrderOrderId} + <input name="orderId" type="text" value="${parameters.orderId!}" disabled/> + </div> + <div> + ${uiLabelMap.OrderOrderItemSeqId} + <select name="orderItemSeqId"> + <#if orderItems?has_content> + <#list orderItems as orderItem> + <option name="orderItemSeqId" value="${orderItem.orderItemSeqId!}">${orderItem.orderItemSeqId!}</option> + </#list> + </#if> + </select> + </div> + <div> + OrderContentTypeId + <select name="orderContentTypeId"> + <#if orderContentTypes?has_content> + <#list orderContentTypes as orderContentType> + <option name="orderContentTypeId" value="${orderContentType.orderContentTypeId!}">${orderContentType.description!}</option> + </#list> + </#if> + </select> + </div> + <div> + <input type="file" name="uploadedFile" class="required" size="25"> + </div> + <div> + <button type="submit"> + ${uiLabelMap.PartyAttachFile} + </button> + </div> + </form> + </div> +</div> Propchange: ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-framework/trunk/applications/order/template/order/AddOrderAttachments.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/ofbiz-framework/trunk/applications/order/template/order/OrderInfo.ftl URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/template/order/OrderInfo.ftl?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/template/order/OrderInfo.ftl (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/template/order/OrderInfo.ftl Sat Jun 22 12:06:43 2019 @@ -227,9 +227,21 @@ under the License. <#if orderContentWrapper.get("IMAGE_URL", "url")?has_content> <tr><td colspan="3"><hr /></td></tr> <tr> - <td class="label"> ${uiLabelMap.OrderImage}</td> + <td class="label"> ${uiLabelMap.CommonAttachments}</td> <td> - <a href="<@ofbizUrl>viewimage?orderId=${orderId}&orderContentTypeId=IMAGE_URL</@ofbizUrl>" target="_orderImage" class="buttontext">${uiLabelMap.OrderViewImage}</a> + <#assign orderContents = EntityQuery.use(delegator).from("OrderContent").where("orderId", orderId!).queryList()!> + <#if orderContents?has_content> + <#list orderContents as orderContent> + <div> + <a href="<@ofbizUrl>stream?contentId=${orderContent.contentId!}</@ofbizUrl>" target="_blank" class="buttontext">${orderContent.contentId}</a> + </div> + </#list> + <#else> + <div> + ${uiLabelMap.CommonNo} ${uiLabelMap.CommonAttachments} + </div> + </#if> + <a href="<@ofbizUrl>AddOrderAttachments?orderId=${orderId!}</@ofbizUrl>" class="buttontext">Add Attachment</a> </td> </tr> </#if> Modified: ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Sat Jun 22 12:06:43 2019 @@ -1965,6 +1965,22 @@ under the License. <response name="error" type="view" value="viewprofile"/> </request-map> + <request-map uri="AddOrderAttachments"> + <security https="true" auth="true"/> + <response name="success" type="view" value="AddOrderAttachments"/> + <response name="success" type="view" value="AddOrderAttachments"/> + </request-map> + <request-map uri="addOrderAttachments"> + <security https="true" auth="true"/> + <event type="service" invoke="uploadOrderContentFile"/> + <response name="success" type="request-redirect" value="orderview"> + <redirect-parameter name="orderId"/> + </response> + <response name="error" type="request-redirect" value="orderview"> + <redirect-parameter name="orderId"/> + </response> + </request-map> + <!-- end of request mappings --> <!-- View Mappings --> @@ -2141,5 +2157,6 @@ under the License. <view-map name="ListQuoteTerms" type="screen" page="component://order/widget/ordermgr/QuoteScreens.xml#ListQuoteTerms"/> <view-map name="splitship" type="screen" page="component://order/widget/ordermgr/OrderEntryOrderScreens.xml#splitship"/> + <view-map name="AddOrderAttachments" type="screen" page="component://order/widget/ordermgr/OrderViewScreens.xml#AddOrderAttachments"/> <!-- end of view mappings --> </site-conf> Modified: ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/widget/ordermgr/OrderViewScreens.xml Sat Jun 22 12:06:43 2019 @@ -607,4 +607,23 @@ under the License. </widgets> </section> </screen> + + <screen name="AddOrderAttachments"> + <section> + <actions> + <set field="titleProperty" value="AddOrderAttachments"/> + <set field="headerItem" value="findorders"/> + <script location="component://order/groovyScripts/order/AddOrderAttachments.groovy"/> + </actions> + <widgets> + <decorator-screen name="CommonOrderViewDecorator"> + <decorator-section name="body"> + <platform-specific> + <html><html-template location="component://order/template/order/AddOrderAttachments.ftl"/></html> + </platform-specific> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> </screens> Modified: ofbiz/ofbiz-framework/trunk/framework/common/config/CommonUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/config/CommonUiLabels.xml?rev=1861853&r1=1861852&r2=1861853&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/common/config/CommonUiLabels.xml (original) +++ ofbiz/ofbiz-framework/trunk/framework/common/config/CommonUiLabels.xml Sat Jun 22 12:06:43 2019 @@ -1072,6 +1072,10 @@ <value xml:lang="zh-CN">å¨</value> <value xml:lang="zh-TW">å¨</value> </property> + <property key="CommonAttachments"> + <value xml:lang="en">Attachments</value> + <value xml:lang="fr">Pièces jointes</value> + </property> <property key="CommonAttentionName"> <value xml:lang="ar">اس٠اÙاÙت٠ا٠</value> <value xml:lang="cs">K rukám</value> |
Free forum by Nabble | Edit this page |