Added new field (manualOnly = Y/N) to ProductStorePromoAppl entity to specify if the promotion will be used only when manually applied by the user.
Implemented ui to manage the new field; in the process, completely refactored the product store promo screen: ftl/bsh-->widgets git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@587459 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -289,7 +289,7 @@ ProductAddProductsUsingDefaultQuantities=Add Products in this Category to the Ca
|
||||
ProductAddPromoRule=Add New Promo Rule
|
||||
ProductAddResultsTo=Add Results To
|
||||
ProductAddRouteSegmentInfo=Add Route Segment Info
|
||||
ProductAddStorePromo=Add Store Promo (select Store, enter optional From Date)
|
||||
ProductAddStorePromo=Add Store Promo
|
||||
ProductAddStorePromoOptionalDate=Add Store Promo (select Promo, enter optional From Date)
|
||||
ProductAddFeatureToCategory=new features to this category
|
||||
ProductAddFeature=Add Feature
|
||||
|
||||
@@ -3739,6 +3739,12 @@ under the License.
|
||||
<field name="fromDate" type="date-time"></field>
|
||||
<field name="thruDate" type="date-time"></field>
|
||||
<field name="sequenceNum" type="numeric"></field>
|
||||
<field name="manualOnly" type="indicator">
|
||||
<description>
|
||||
If set to Y then the promotion is not automatically evaluated, but only if it
|
||||
is manually added to the cart.
|
||||
</description>
|
||||
</field>
|
||||
<prim-key field="productStoreId"/>
|
||||
<prim-key field="productPromoId"/>
|
||||
<prim-key field="fromDate"/>
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import org.ofbiz.entity.*;
|
||||
import org.ofbiz.entity.util.*;
|
||||
import org.ofbiz.base.util.*;
|
||||
import org.ofbiz.widget.html.*;
|
||||
|
||||
activeOnly = !"false".equals(request.getParameter("activeOnly"));
|
||||
userEntered = !"false".equals(request.getParameter("userEntered"));
|
||||
|
||||
nowTimestampString = UtilDateTime.nowTimestamp().toString();
|
||||
|
||||
productStorePromoAndAppls = null;
|
||||
if (productStore != null) {
|
||||
constraintMap = UtilMisc.toMap("productStoreId", productStoreId);
|
||||
if (userEntered) {
|
||||
constraintMap.put("userEntered", "Y");
|
||||
}
|
||||
productStorePromoAndAppls = delegator.findByAnd("ProductStorePromoAndAppl", constraintMap, UtilMisc.toList("sequenceNum", "productPromoId"));
|
||||
if (activeOnly) {
|
||||
productStorePromoAndAppls = EntityUtil.filterByDate(productStorePromoAndAppls);
|
||||
}
|
||||
}
|
||||
|
||||
productPromos = delegator.findByAnd("ProductPromo", UtilMisc.toMap("userEntered", "Y"), UtilMisc.toList("promoName"));
|
||||
|
||||
context.put("activeOnly", activeOnly);
|
||||
context.put("userEntered", userEntered);
|
||||
context.put("nowTimestampString", nowTimestampString);
|
||||
context.put("productStorePromoAndAppls", productStorePromoAndAppls);
|
||||
context.put("productPromos", productPromos);
|
||||
|
||||
int viewIndex = 0;
|
||||
int viewSize = 20;
|
||||
int highIndex = 0;
|
||||
int lowIndex = 0;
|
||||
int listSize = 0;
|
||||
|
||||
try {
|
||||
viewIndex = Integer.valueOf((String) parameters.get("VIEW_INDEX")).intValue();
|
||||
} catch (Exception e) {
|
||||
viewIndex = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
viewSize = Integer.valueOf((String) parameters.get("VIEW_SIZE")).intValue();
|
||||
} catch (Exception e) {
|
||||
viewSize = 20;
|
||||
}
|
||||
|
||||
if (productStorePromoAndAppls != null) {
|
||||
listSize = productStorePromoAndAppls.size();
|
||||
}
|
||||
|
||||
lowIndex = viewIndex * viewSize;
|
||||
highIndex = (viewIndex + 1) * viewSize;
|
||||
if (listSize < highIndex) {
|
||||
highIndex = listSize;
|
||||
}
|
||||
|
||||
context.put("viewIndex", viewIndex);
|
||||
context.put("viewSize", viewSize);
|
||||
context.put("listSize", listSize);
|
||||
context.put("lowIndex", lowIndex);
|
||||
context.put("highIndex", highIndex);
|
||||
@@ -1,131 +0,0 @@
|
||||
<#--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<#if activeOnly>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&userEntered=${userEntered?string}&activeOnly=false</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonActiveInactive}]</a>
|
||||
<#else>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&userEntered=${userEntered?string}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonActiveOnly}]</a>
|
||||
</#if>
|
||||
<#if userEntered>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&activeOnly=${activeOnly?string}&userEntered=false</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonUserAutoEntered}]</a>
|
||||
<#else>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&activeOnly=${activeOnly?string}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonUserEnteredOnly}]</a>
|
||||
</#if>
|
||||
<br/>
|
||||
<h3>${uiLabelMap.CommonShow}
|
||||
<#if activeOnly>${uiLabelMap.CommonActiveOnly}<#else>${uiLabelMap.CommonActiveInactive}</#if>
|
||||
${uiLabelMap.CommonAnd}
|
||||
<#if userEntered>${uiLabelMap.CommonUserEnteredOnly}<#else>${uiLabelMap.CommonUserAutoEntered}</#if>
|
||||
</h3>
|
||||
|
||||
<#if productStoreId?exists && productStore?exists>
|
||||
<#if (listSize > 0)>
|
||||
<table border="0" cellpadding="2">
|
||||
<tr>
|
||||
<td align="right">
|
||||
<b>
|
||||
<#if (viewIndex > 0)>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&VIEW_SIZE=${viewSize}&VIEW_INDEX=${viewIndex-1}&activeOnly=${activeOnly.toString()}&userEntered=${userEntered.toString()}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonPrevious}]</a> |
|
||||
</#if>
|
||||
<#if (listSize > 0)>
|
||||
<span class="tabletext">${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}</span>
|
||||
</#if>
|
||||
<#if (listSize > highIndex)>
|
||||
| <a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&VIEW_SIZE=${viewSize}&VIEW_INDEX=${viewIndex+1}&activeOnly=${activeOnly.toString()}&userEntered=${userEntered.toString()}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonNext}]</a>
|
||||
</#if>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</#if>
|
||||
|
||||
<table border="1" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td><div class="tabletext"><b>${uiLabelMap.ProductPromoNameId}</b></div></td>
|
||||
<td><div class="tabletext"><b>${uiLabelMap.CommonFromDateTime}</b></div></td>
|
||||
<td align="center"><div class="tabletext"><b>${uiLabelMap.ProductThruDateTimeSequence}</b></div></td>
|
||||
<td><div class="tabletext"><b> </b></div></td>
|
||||
</tr>
|
||||
<#if (listSize > 0)>
|
||||
<#assign line = 0>
|
||||
<#list productStorePromoAndAppls[lowIndex..highIndex-1] as productStorePromoAndAppl>
|
||||
<#assign line = line+1>
|
||||
<tr valign="middle">
|
||||
<td><a href="<@ofbizUrl>EditProductPromo?productPromoId=${(productStorePromoAndAppl.productPromoId)?if_exists}</@ofbizUrl>" class="buttontext">${(productStorePromoAndAppl.promoName)?if_exists} [${(productStorePromoAndAppl.productPromoId)?if_exists}]</a></td>
|
||||
<#assign hasntStarted = false>
|
||||
<#if productStorePromoAndAppl.getTimestamp("fromDate")?exists && Static["org.ofbiz.base.util.UtilDateTime"].nowTimestamp().before(productStorePromoAndAppl.getTimestamp("fromDate"))> <#assign hasntStarted = true> </#if>
|
||||
<td><div class="tabletext" <#if hasntStarted> style="color: red;"</#if> >${productStorePromoAndAppl.getTimestamp("fromDate").toString()}</div></td>
|
||||
<td align="center">
|
||||
<#assign hasExpired = false>
|
||||
<#if productStorePromoAndAppl.getTimestamp("thruDate")?exists && Static["org.ofbiz.base.util.UtilDateTime"].nowTimestamp().after(productStorePromoAndAppl.getTimestamp("thruDate"))> <#assign hasExpired = true></#if>
|
||||
<form method="post" action="<@ofbizUrl>updateProductStorePromoAppl</@ofbizUrl>" name="lineForm${line}">
|
||||
<input type="hidden" name="productStoreId" value="${(productStorePromoAndAppl.productStoreId)?if_exists}">
|
||||
<input type="hidden" name="productPromoId" value="${(productStorePromoAndAppl.productPromoId)?if_exists}">
|
||||
<input type="hidden" name="fromDate" value="${(productStorePromoAndAppl.fromDate)?if_exists}">
|
||||
<input type="text" size="25" name="thruDate" value="${(productStorePromoAndAppl.thruDate)?if_exists}" class="inputBox" style="<#if (hasExpired) >color: red;</#if>">
|
||||
<a href="javascript:call_cal(document.lineForm${line}.thruDate, '${(productStorePromoAndAppl.thruDate)?default(nowTimestampString)}');"><img src="<@ofbizContentUrl>/images/cal.gif</@ofbizContentUrl>" width="16" height="16" border="0" alt="Calendar"></a>
|
||||
<input type="text" size="5" name="sequenceNum" value="${(productStorePromoAndAppl.sequenceNum)?if_exists}" class="inputBox">
|
||||
<input type="submit" value="${uiLabelMap.CommonUpdate}" style="font-size: x-small;">
|
||||
</form>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="<@ofbizUrl>deleteProductStorePromoAppl?productStoreId=${(productStorePromoAndAppl.productStoreId)?if_exists}&productPromoId=${(productStorePromoAndAppl.productPromoId)?if_exists}&fromDate=${Static["org.ofbiz.base.util.UtilFormatOut"].encodeQueryValue(productStorePromoAndAppl.getTimestamp("fromDate").toString())}</@ofbizUrl>" class="buttontext">
|
||||
[${uiLabelMap.CommonDelete}]</a>
|
||||
</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
</table>
|
||||
<#if (listSize > 0)>
|
||||
<table border="0" cellpadding="2">
|
||||
<tr>
|
||||
<td align="right">
|
||||
<b>
|
||||
<#if (viewIndex > 0)>
|
||||
<a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&VIEW_SIZE=${viewSize}&VIEW_INDEX=${viewIndex-1}&activeOnly=${activeOnly.toString()}&userEntered=${userEntered.toString()}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonPrevious}]</a> |
|
||||
</#if>
|
||||
<#if (listSize > 0)>
|
||||
<span class="tabletext">${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}</span>
|
||||
</#if>
|
||||
<#if (listSize > highIndex)>
|
||||
| <a href="<@ofbizUrl>EditProductStorePromos?productStoreId=${productStoreId}&VIEW_SIZE=${viewSize}&VIEW_INDEX=${viewIndex+1}&activeOnly=${activeOnly.toString()}&userEntered=${userEntered.toString()}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonNext}]</a>
|
||||
</#if>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</#if>
|
||||
|
||||
<br/>
|
||||
<form method="post" action="<@ofbizUrl>createProductStorePromoAppl</@ofbizUrl>" style="margin: 0;" name="addNewForm">
|
||||
<input type="hidden" name="productStoreId" value="${productStoreId?if_exists}"/>
|
||||
<input type="hidden" name="tryEntity" value="true"/>
|
||||
|
||||
<h2>${uiLabelMap.ProductAddStorePromoOptionalDate}:</h2>
|
||||
<br/>
|
||||
<select name="productPromoId" class="selectBox">
|
||||
<#list productPromos as productPromo>
|
||||
<option value="${productPromo.productPromoId?if_exists}">${productPromo.promoName?if_exists} [${productPromo.productPromoId?if_exists}]</option>
|
||||
</#list>
|
||||
</select> <span class="tabletext">${uiLabelMap.ProductNoteUserPromotionEntered}</span>
|
||||
<br/>
|
||||
<input type="text" size="25" name="fromDate" class="inputBox"/>
|
||||
<a href="javascript:call_cal(document.addNewForm.fromDate, '${nowTimestampString}');"><img src="<@ofbizContentUrl>/images/cal.gif</@ofbizContentUrl>" width="16" height="16" border="0" alt="Calendar"/></a>
|
||||
<input type="submit" value="${uiLabelMap.CommonAdd}"/>
|
||||
</form>
|
||||
</#if>
|
||||
@@ -771,4 +771,40 @@
|
||||
</field>
|
||||
<field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
|
||||
</form>
|
||||
|
||||
<form name="ListProductStorePromos" type="list" list-name="productStorePromoAndAppls" target="updateProductStorePromoAppl">
|
||||
<field name="productStoreId"><hidden/></field>
|
||||
<field name="productPromoId" widget-style="buttontext">
|
||||
<hyperlink target="EditProductPromo?productPromoId=${productPromoId}"
|
||||
description="${productPromoId}" also-hidden="true"/>
|
||||
</field>
|
||||
<field name="promoName"><display/></field>
|
||||
<field name="fromDate"><display/></field>
|
||||
<field name="thruDate"><date-time/></field>
|
||||
<field name="sequenceNum"><text/></field>
|
||||
<field name="manualOnly">
|
||||
<drop-down allow-empty="true">
|
||||
<option key="Y" description="${uiLabelMap.CommonY}"/>
|
||||
<option key="N" description="${uiLabelMap.CommonN}"/>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="submitButton" title="${uiLabelMap.CommonUpdate}"><submit button-type="button"/></field>
|
||||
</form>
|
||||
<form name="CreateProductStorePromo" type="single" target="createProductStorePromoAppl">
|
||||
<field name="productStoreId"><hidden/></field>
|
||||
<field name="productPromoId">
|
||||
<drop-down allow-empty="false">
|
||||
<entity-options entity-name="ProductPromo" description="[${productPromoId}] ${promoName}"/>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="fromDate" tooltip="${uiLabelMap.CommonRequired}" widget-style="required"><date-time/></field>
|
||||
<field name="thruDate"><date-time/></field>
|
||||
<field name="manualOnly">
|
||||
<drop-down>
|
||||
<option key="N" description="${uiLabelMap.CommonN}"/>
|
||||
<option key="Y" description="${uiLabelMap.CommonY}"/>
|
||||
</drop-down>
|
||||
</field>
|
||||
<field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit button-type="button"/></field>
|
||||
</form>
|
||||
</forms>
|
||||
|
||||
@@ -88,7 +88,7 @@ under the License.
|
||||
<container>
|
||||
<label style="head3">${uiLabelMap.CommonView}</label>
|
||||
<link target="FindProductPromo" text="${uiLabelMap.CommonAll}" style="buttontext"/>
|
||||
<link target="FindProductPromo?userEntered=Y" text="${uiLabelMap.ProductPromotionManual}" style="buttontext"/>
|
||||
<link target="FindProductPromo?userEntered=Y" text="${uiLabelMap.CommonUserEnteredOnly}" style="buttontext"/>
|
||||
<link target="FindProductPromo?userEntered=N" text="${uiLabelMap.ProductPromotionImported}" style="buttontext"/>
|
||||
</container>
|
||||
<include-form name="GoToProductPromoCode" location="component://product/webapp/catalog/promo/PromoForms.xml"/>
|
||||
|
||||
@@ -100,14 +100,37 @@ under the License.
|
||||
<set field="productStoreId" from-field="parameters.productStoreId"/>
|
||||
<entity-one entity-name="ProductStore" value-name="productStore" auto-field-map="true"/>
|
||||
|
||||
<script location="component://product/webapp/catalog/WEB-INF/actions/store/EditProductStorePromos.bsh"/>
|
||||
<set field="userEntered" from-field="parameters.userEntered"/>
|
||||
<set field="activeOnly" from-field="parameters.activeOnly" default-value="true"/>
|
||||
<entity-condition entity-name="ProductStorePromoAndAppl" list-name="productStorePromoAndAppls" filter-by-date="${activeOnly}">
|
||||
<condition-list combine="and">
|
||||
<condition-expr field-name="userEntered" env-name="userEntered" ignore-if-empty="true"/>
|
||||
<condition-expr field-name="productStoreId" env-name="productStoreId"/>
|
||||
</condition-list>
|
||||
<order-by field-name="sequenceNum"/>
|
||||
<order-by field-name="productPromoId"/>
|
||||
</entity-condition>
|
||||
</actions>
|
||||
<widgets>
|
||||
<decorator-screen name="CommonProductStoreDecorator" location="${parameters.mainDecoratorLocation}">
|
||||
<decorator-section name="body">
|
||||
<platform-specific>
|
||||
<html><html-template location="component://product/webapp/catalog/store/EditProductStorePromos.ftl"/></html>
|
||||
</platform-specific>
|
||||
<container>
|
||||
<label style="head3">${uiLabelMap.CommonView}</label>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}" text="${uiLabelMap.CommonAll}" style="buttontext"/>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}&userEntered=Y" text="${uiLabelMap.CommonUserEnteredOnly}" style="buttontext"/>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}&userEntered=N" text="${uiLabelMap.ProductPromotionImported}" style="buttontext"/>
|
||||
</container>
|
||||
<container>
|
||||
<label style="head3">${uiLabelMap.CommonView} ${uiLabelMap.CommonActiveInactive}</label>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}&activeOnly=N" text="${uiLabelMap.CommonAll}" style="buttontext"/>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}&activeOnly=N&userEntered=Y" text="${uiLabelMap.CommonUserEnteredOnly}" style="buttontext"/>
|
||||
<link target="EditProductStorePromos?productStoreId=${productStoreId}&activeOnly=N&userEntered=N" text="${uiLabelMap.ProductPromotionImported}" style="buttontext"/>
|
||||
</container>
|
||||
<include-form name="ListProductStorePromos" location="component://product/webapp/catalog/store/ProductStoreForms.xml"/>
|
||||
<container>
|
||||
<label style="head2">${uiLabelMap.ProductAddStorePromo}</label>
|
||||
</container>
|
||||
<include-form name="CreateProductStorePromo" location="component://product/webapp/catalog/store/ProductStoreForms.xml"/>
|
||||
</decorator-section>
|
||||
</decorator-screen>
|
||||
</widgets>
|
||||
|
||||
Reference in New Issue
Block a user