On Thu, Aug 14, 2008 at 2:07 PM, <[hidden email]> wrote:
> Author: bibryam > Date: Thu Aug 14 01:37:52 2008 > New Revision: 685809 > > URL: http://svn.apache.org/viewvc?rev=685809&view=rev > Log: > Missed these files in my previous commit. > > Added: > > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > (with props) > > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > (with props) > > Added: > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy?rev=685809&view=auto > > ============================================================================== > --- > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > (added) > +++ > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > Thu Aug 14 01:37:52 2008 > @@ -0,0 +1,311 @@ > +/* > + * 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.lang.*; > +import java.util.*; > +import java.text.NumberFormat; > +import org.ofbiz.base.util.*; > +import org.ofbiz.service.*; > +import org.ofbiz.entity.*; > +import org.ofbiz.entity.condition.*; > +import org.ofbiz.entity.util.*; > +import org.ofbiz.webapp.taglib.*; > +import org.ofbiz.webapp.stats.VisitHandler; > +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; > +import org.ofbiz.product.catalog.*; > +import org.ofbiz.product.category.*; > +import org.ofbiz.product.product.ProductWorker; > +import org.ofbiz.product.product.ProductContentWrapper; > +import org.ofbiz.product.product.ProductSearch; > +import org.ofbiz.product.product.ProductSearchSession; > +import org.ofbiz.product.store.*; > + > +inlineProductId = request.getAttribute("inlineProductId"); > +inlineCounter = request.getAttribute("inlineCounter"); > +context.inlineCounter = inlineCounter; > +context.inlineProductId = inlineProductId; > + > +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); > +catalogName = CatalogWorker.getCatalogName(request); > +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); > + > +if (inlineProductId) { > + inlineProduct = delegator.findByPrimaryKeyCache("Product", [productId > : inlineProductId]); > + if (inlineProduct) { > + context.product = inlineProduct; > + contentWrapper = new ProductContentWrapper(inlineProduct, > request); > + context.put("title", contentWrapper.get("PRODUCT_NAME")); > + context.put("metaDescription", contentWrapper.get("DESCRIPTION")); > + productTemplate = product.detailScreen; > + if (productTemplate) { > + detailScreen = productTemplate; > + } > + } > +} > + > +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); > +if (templatePathPrefix) { > + detailScreen = templatePathPrefix + detailScreen; > +} > +context.detailScreen = detailScreen; > + > +String buildNext(Map map, List order, String current, String prefix, Map > featureTypes) { > + def ct = 0; > + def buf = new StringBuffer(); > + buf.append("function listFT" + inlineCounter + current + prefix + "() > { "); > + buf.append("document.forms[\"configform\"].elements[\"FT" + > inlineCounter + current + "\"].options.length = 1;"); > + buf.append("document.forms[\"configform\"].elements[\"FT" + > inlineCounter + current + "\"].options[0] = new Option(\"" + > featureTypes[current] + "\",\"\",true,true);"); > + map.each { key, value -> > + def optValue = null; > + > + if (order.indexOf(current) == (order.size()-1)) { > + optValue = value.iterator().next(); > + } else { > + optValue = prefix + "_" + ct; > + } > + > + buf.append("document.forms[\"configform\"].elements[\"FT" + > inlineCounter + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + > key + "\",\"" + optValue + "\");"); > + ct++; > + } > + buf.append(" }"); > + if (order.indexOf(current) < (order.size()-1)) { > + ct = 0; > + map.each { key, value -> > + def nextOrder = order.get(order.indexOf(current)+1); > + def newPrefix = prefix + "_" + ct; > + buf.append(buildNext(value, order, nextOrder, newPrefix, > featureTypes)); > + ct++; > + } > + } > + return buf.toString(); > +} > + > +cart = ShoppingCartEvents.getCartObject(request); > + > +// set the content path prefix > +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); > +context.contentPathPrefix = contentPathPrefix; > + > +// get the product detail information > +if (inlineProduct) { > + inlineProductId = inlineProduct.productId; > + productTypeId = inlineProduct.productTypeId; > + featureTypes = [:]; > + featureOrder = []; > + > + // make the productContentWrapper > + productContentWrapper = new ProductContentWrapper(inlineProduct, > request); > + context.productContentWrapper = productContentWrapper; > + > + // get the main detail image (virtual or single product) > + mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL"); > + if (mainDetailImage) { > + mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + > mainDetailImage; > + mainDetailImageUrl = > URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8"); > + context.mainDetailImageUrl = mainDetailImageUrl; > + } > + > + > + // get the product price > + webSiteId = CatalogWorker.getWebSiteId(request); > + autoUserLogin = request.getSession().getAttribute("autoUserLogin"); > + if (cart.isSalesOrder()) { > + // sales order: run the "calculateProductPrice" service > + priceContext = [product : inlineProduct, prodCatalogId : > currentCatalogId, > + currencyUomId : cart.getCurrency(), autoUserLogin : > autoUserLogin]; > + priceContext.webSiteId = webSiteId; > + priceContext.productStoreId = productStoreId; > + priceContext.checkIncludeVat = "Y"; > + priceContext.agreementId = cart.getAgreementId(); > + priceContext.partyId = cart.getPartyId(); // IMPORTANT: must put > this in, or price will be calculated for the CSR instead of the customer > + priceMap = dispatcher.runSync("calculateProductPrice", > priceContext); > + context.priceMap = priceMap; > + } else { > + // purchase order: run the "calculatePurchasePrice" service > + priceContext = [product : inlineProduct, currencyUomId : > cart.getCurrency(), > + partyId : cart.getPartyId(), userLogin : userLogin]; > + priceMap = dispatcher.runSync("calculatePurchasePrice", > priceContext); > + context.priceMap = priceMap; > + } > + > + > + context.variantTree = null; > + context.variantTreeSize = null; > + context.variantSample = null; > + context.variantSampleKeys = null; > + context.variantSampleSize = null; > + if ("Y".equals(inlineProduct.isVirtual)) { > + if > ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod(delegator, > inlineProductId))) { > + context.featureLists = > ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct); > + } else { > + featureMap = dispatcher.runSync("getProductFeatureSet", > [productId : inlineProductId]); > + featureSet = featureMap.featureSet; > + if (featureSet) { > + variantTreeMap = > dispatcher.runSync("getProductVariantTree", [productId : inlineProductId, > featureOrder : featureSet, productStoreId : productStoreId]); > + variantTree = variantTreeMap.variantTree; > + imageMap = variantTreeMap.variantSample; > + virtualVariant = variantTreeMap.virtualVariant; > + context.virtualVariant = virtualVariant; > + if (variantTree) { > + context.variantTree = variantTree; > + context.variantTreeSize = variantTree.size(); > + } > + if (imageMap) { > + context.variantSample = imageMap; > + context.variantSampleKeys = imageMap.keySet(); > + context.variantSampleSize = imageMap.size(); > + } > + context.featureSet = featureSet; > + > + if (variantTree) { > + featureOrder = new LinkedList(featureSet); > + featureOrder.each { featureKey -> > + featureValue = > delegator.findByPrimaryKeyCache("ProductFeatureType", [productFeatureTypeId > : featureKey]); > + fValue = featureValue.get("description") ?: > featureValue.productFeatureTypeId; > + featureTypes[featureKey] = fValue; > + } > + } > + context.featureTypes = featureTypes; > + context.featureOrder = featureOrder; > + if (featureOrder) { > + context.featureOrderFirst = featureOrder[0]; > + } > + > + if (variantTree && imageMap) { > + jsBuf = new StringBuffer(); > + jsBuf.append("<script language=\"JavaScript\">"); > + jsBuf.append("var DET" + inlineCounter + "= new > Array(" + variantTree.size() + ");"); > + jsBuf.append("var IMG" + inlineCounter + " = new > Array(" + variantTree.size() + ");"); > + jsBuf.append("var OPT" + inlineCounter + " = new > Array(" + featureOrder.size() + ");"); > + jsBuf.append("var VIR" + inlineCounter + " = new > Array(" + virtualVariant.size() + ");"); > + jsBuf.append("var detailImageUrl" + inlineCounter + " > = null;"); > + featureOrder.eachWithIndex { feature, i -> > + jsBuf.append("OPT" + inlineCounter + "[" + i + "] > = \"FT" + inlineCounter + feature + "\";"); > + } > + virtualVariant.eachWithIndex { variant, i -> > + jsBuf.append("VIR" + inlineCounter + "[" + i + "] > = \"" + variant + "\";"); > + } > + > + // build the top level > + topLevelName = featureOrder[0]; > + jsBuf.append("function list" + inlineCounter + > topLevelName + "() {"); > + > jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter > + topLevelName + "\"].options.length = 1;"); > + > jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter > + topLevelName + "\"].options[0] = new Option(\"" + > featureTypes[topLevelName] + "\",\"\",true,true);"); > + if (variantTree) { > + featureOrder.each { featureKey -> > + > jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter > + featureKey + "\"].options.length = 1;"); > + } > + firstDetailImage = null; > + firstLargeImage = null; > + counter = 0; > + variantTree.each { key, value -> > + opt = null; > + if (featureOrder.size() == 1) { > + opt = value.iterator().next(); > + } else { > + opt = counter as String; > + } > + // create the variant content wrapper > + contentWrapper = new > ProductContentWrapper(imageMap[key], request); > + > + // initial image paths > + detailImage = > contentWrapper.get("DETAIL_IMAGE_URL") ?: > productContentWrapper.get("DETAIL_IMAGE_URL"); > + largeImage = > contentWrapper.get("LARGE_IMAGE_URL") ?: > productContentWrapper.get("LARGE_IMAGE_URL"); > + > + // full image URLs > + detailImageUrl = null; > + largeImageUrl = null; > + > + // append the content prefix > + if (detailImage) { > + detailImageUrl = > ContentUrlTag.getContentPrefix(request) + detailImage; > + // base64 encode the image url for a > little protection > + detailImageUrl = > URLEncoder.encode(Base64.base64Encode(detailImageUrl), "UTF-8"); > + } > + if (largeImage) { > + largeImageUrl = > ContentUrlTag.getContentPrefix(request) + largeImage; > + } > + > + > jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter > + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + > "\",\"" + opt + "\");"); > + jsBuf.append("DET" + inlineCounter + "[" + > counter + "] = \"" + detailImageUrl +"\";"); > + jsBuf.append("IMG" + inlineCounter + "[" + > counter + "] = \"" + largeImageUrl +"\";"); > + > + if (!firstDetailImage) { > + firstDetailImage = detailImageUrl; > + } > + if (!firstLargeImage) { > + firstLargeImage = largeImage; > + } > + counter++; > + } > + context.firstDetailImage = firstDetailImage; > + context.firstLargeImage = firstLargeImage; > + } > + jsBuf.append("}"); > + > + // build dynamic lists > + if (variantTree) { > + variantTree.values().eachWithIndex { varTree, > topLevelKeysCt -> > + cnt = "" + topLevelKeysCt; > + if (varTree instanceof Map) { > + jsBuf.append(buildNext(varTree, > featureOrder, featureOrder[1], cnt, featureTypes)); > + } > + } > + } > + > + // make a list of variant sku with requireAmount > + variantsRes = > dispatcher.runSync("getAssociatedProducts", [productId : inlineProductId, > type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : > currentCatalogId]); > + variants = variantsRes.assocProducts; > + if (variants) { > + amt = new StringBuffer(); > + amt.append("function checkAmtReq" + inlineCounter > + "(sku) { "); > + // Create the javascript to return the price for > each variant > + variantPriceJS = new StringBuffer(); > + variantPriceJS.append("function getVariantPrice" + > inlineCounter + "(sku) { "); > + // Format to apply the currency code to the > variant price in the javascript > + productStore = > ProductStoreWorker.getProductStore(request); > + localeString = productStore.defaultLocaleString; > + if (localeString) { > + locale = UtilMisc.parseLocale(localeString); > + } > + numberFormat = > NumberFormat.getCurrencyInstance(locale); > + variants.each { variantAssoc -> > + variant = > variantAssoc.getRelatedOne("AssocProduct"); > + // Get the price for each variant. Reuse the > priceContext already setup for virtual product above and replace the product > + if (cart.isSalesOrder()) { > + // sales order: run the > "calculateProductPrice" service > + priceContext.product = variant; > + variantPriceMap = > dispatcher.runSync("calculateProductPrice", priceContext); > + } > + amt.append(" if (sku == \"" + > variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; > "); > + variantPriceJS.append(" if (sku == \"" + > variant.productId + "\") return \"" + > numberFormat.format(variantPriceMap.basePrice) + "\"; "); > + } > + amt.append(" } "); > + variantPriceJS.append(" } "); > + } > + jsBuf.append(amt.toString()); > + jsBuf.append(variantPriceJS.toString()); > + jsBuf.append("</script>"); > + > + context.virtualJavaScript = jsBuf.toString(); > + } > + } > + } > + } > +} > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > > ------------------------------------------------------------------------------ > svn:keywords = Date Rev Author URL Id > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl?rev=685809&view=auto > > ============================================================================== > --- > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > (added) > +++ > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > Thu Aug 14 01:37:52 2008 > @@ -0,0 +1,389 @@ > +<#-- > +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. > +--> > + > +${virtualJavaScript?if_exists} > +<#assign addJavaScript = requestAttributes.addJavaScript/> > +<#if (addJavaScript == 0)> > +<script language="JavaScript" type="text/javascript"> > + > + function popupDetailInline(inlineCounter) { > + var imageField = 'detailImage' + inlineCounter; > + var defaultDetailImage = document.getElementById(imageField); > + if (defaultDetailImage == null || defaultDetailImage == "null") { > + defaultDetailImage = "_NONE_"; > + } > + var fieldName = 'detailImageUrl' + inlineCounter; > + if (window[fieldName] == null || window[fieldName] == "null") { > + window[fieldName] = defaultDetailImage; > + } > + > + if (window[fieldName] == "_NONE_") { > + alert("No detail image available to display."); > + return; > + } > + popUp("<@ofbizUrl>detailImage?detail=" + window[fieldName] + > "</@ofbizUrl>", 'detailImage', '400', '550'); > + } > + > + function setAddProductIdInline(inlineCounter, name) { > + var add_product_id = 'add_product_id' + inlineCounter; > + var product_id_display = 'product_id_display' + inlineCounter; > + document.configform[add_product_id].value = name; > + if (name == '' || name == 'NULL' || isVirtualInline(inlineCounter, > name) == true) { > + //document.configform.quantity.disabled = true; > + var elem = document.getElementById(product_id_display); > + var txt = document.createTextNode(''); > + if(elem.hasChildNodes()) { > + elem.replaceChild(txt, elem.firstChild); > + } else { > + elem.appendChild(txt); > + } > + > + checkOtion(inlineCounter); > + } else { > + //document.configform.quantity.disabled = false; > + var elem = document.getElementById(product_id_display); > + var txt = document.createTextNode(name); > + if(elem.hasChildNodes()) { > + elem.replaceChild(txt, elem.firstChild); > + } else { > + elem.appendChild(txt); > + } > + } > + } > + > + function checkOtion(inlineCounter) { I think it would be "checkOption" grammatically - but its not a big concern :) - Vikas > + var option = document.getElementById(inlineCounter.substring(0, > inlineCounter.length - 2)); > + if (option.checked) { > + option.checked=false; > + } > + } > + > + function setVariantPriceInline(inlineCounter, sku) { > + var variant_price_display = 'variant_price_display' + > inlineCounter; > + if (sku == '' || sku == 'NULL' || isVirtualInline(inlineCounter, > sku) == true) { > + var elem = document.getElementById(variant_price_display); > + var txt = document.createTextNode(''); > + if(elem.hasChildNodes()) { > + elem.replaceChild(txt, elem.firstChild); > + } else { > + elem.appendChild(txt); > + } > + } > + else { > + var elem = document.getElementById(variant_price_display); > + var functionName = 'getVariantPrice' + inlineCounter; > + var price = window[functionName](sku); > + var txt = document.createTextNode('+' + price); > + if(elem.hasChildNodes()) { > + elem.replaceChild(txt, elem.firstChild); > + } else { > + elem.appendChild(txt); > + } > + } > + } > + function isVirtualInline(inlineCounter, product) { > + var isVirtual = false; > + var fieldName = 'VIR' + inlineCounter; > + <#if virtualJavaScript?exists> > + for (i = 0; i < window[fieldName].length; i++) { > + if (window[fieldName][i] == product) { > + isVirtual = true; > + } > + } > + </#if> > + return isVirtual; > + } > + > + function toggleAmtInline(inlineCounter, toggle) { > + var fieldName = 'add_amount' + inlineCounter; > + if (toggle == 'Y') { > + changeObjectVisibility(fieldName, "visible"); > + } > + > + if (toggle == 'N') { > + changeObjectVisibility(fieldName, "hidden"); > + } > + } > + > + function findIndexInline(varname, name ) { > + for (i = 0; i < window[varname].length; i++) { > + if ( window[varname][i] == name) { > + return i; > + } > + } > + return -1; > + } > + > + function checkOptionToggle(inlineCounter, disable) { > + var index = inlineCounter.indexOf('_'); > + var optionElementName = inlineCounter.substring(0,index); > + var option = document.getElementById(optionElementName); > + if ("true" == disable) { > + option.disabled = true; > + if (option.checked == true) { > + option.checked == false; > + } > + } else { > + //check all virtual product for the option > + } > + } > + > + function checkOptionVariants(optionName) { > + var option = document.getElementById(optionName); > + if (option.checked == false) { > + return false; > + } > + > + var fieldName = "add_product_id" + optionName + "_"; > + var index = 15 + optionName.toString().length; > + var cform = document.forms["configform"]; > + var len = cform.elements.length; > + for (var i = 0; i < len; i++) { > + var element = cform.elements[i]; > + if (element.name.substring(0, index) == fieldName) { > + if (element.value == '' || element.value == 'NULL') { > + option.checked = false; > + alert('Please select all features first'); > + return false; > + } > + } > + } > + } > + > + function getListInline(inlineCounter, name, index, src) { > + currentFeatureIndex = findIndexInline('OPT'+inlineCounter, name); > + > + if (currentFeatureIndex == 0) { > + // set the images for the first selection > + if ([index] != null) { > + if (document.images['mainImage'+ inlineCounter] != null) { > + document.images['mainImage'+ inlineCounter].src = > window['IMG'+ inlineCounter][index]; > + window['detailImageUrl'+ inlineCounter] = > window['DET'+ inlineCounter][index]; > + } > + } > + > + // set the drop down index for swatch selection > + document.forms["configform"].elements[name].selectedIndex = > (index*1)+1; > + } > + > + if (currentFeatureIndex < (window['OPT'+ inlineCounter].length-1)) > { > + // eval the next list if there are more > + var selectedValue = > document.forms["configform"].elements[name].options[(index*1)+1].value; > + if (index == -1) { > + var featureOrderFirst = window['OPT'+ > inlineCounter][(currentFeatureIndex)].toString(); > + var length = featureOrderFirst.length; > + featureOrderFirst = featureOrderFirst.substring(2, > length); > + var Variable1 = eval("list" + featureOrderFirst + "()"); > + } else { > + var Variable1 = eval("list" + window['OPT'+ > inlineCounter][(currentFeatureIndex+1)] + selectedValue + "()"); > + } > + > + // set the product ID to NULL to trigger the alerts > + setAddProductIdInline(inlineCounter, 'NULL'); > + > + // set the variant price to NULL > + setVariantPriceInline(inlineCounter, 'NULL'); > + > + //checkOptionToggle(inlineCounter, 'false'); > + } else { > + // this is the final selection -- locate the selected index of > the last selection > + var indexSelected = > document.forms["configform"].elements[name].selectedIndex; > + > + // using the selected index locate the sku > + var sku = > document.forms["configform"].elements[name].options[indexSelected].value; > + > + // set the product ID > + setAddProductIdInline(inlineCounter, sku); > + > + // set the variant price > + setVariantPriceInline(inlineCounter, sku); > + > + // check for amount box > + var functionName = 'checkAmtReq' + inlineCounter; > + toggleAmtInline(inlineCounter, window[functionName](sku)); > + > + //checkOptionToggle(inlineCounter, 'true'); > + } > + } > + > + > + </script> > +</#if> > + > +<#assign addedFeatureTreeJavaScript = > requestAttributes.addedFeatureTreeJavaScript?default("N")/> > +<#if product.virtualVariantMethodEnum?if_exists == "VV_FEATURETREE" && > featureLists?has_content && ("N" == addedFeatureTreeJavaScript)> > + ${setRequestAttribute("addedFeatureTreeJavaScript", "Y")} > + <script language="JavaScript" type="text/javascript"> > + function checkRadioButtoninline(inlineCounter, productId) { > + var add_product_id = 'add_product_id' + inlineCounter; > + <#list featureLists as featureList> > + <#list featureList as feature> > + <#if feature_index == 0> > + var myList = document.getElementById("FT" > +inlineCounter + "${feature.productFeatureTypeId}"); > + if (myList.options[0].selected == true) { > + document.configform[add_product_id].value = > 'NULL'; > + return; > + } > + <#break> > + </#if> > + </#list> > + </#list> > + document.configform[add_product_id].value = productId; > + } > + </script> > +</#if> > + > + > +<#assign price = priceMap?if_exists/> > +<div id="inlineproductdetail${inlineCounter}"> > +<table border="0" cellpadding="2" cellspacing="0" width="100%"> > + <tr> > + <td align="left" valign="top" width="0"> > + <#assign productLargeImageUrl = > productContentWrapper.get("LARGE_IMAGE_URL")?if_exists> > + <#if firstLargeImage?has_content> > + <#assign productLargeImageUrl = firstLargeImage> > + </#if> > + <#if productLargeImageUrl?has_content> > + <input type="hidden" name="detailImage${inlineCounter}" > value="${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}"/> > + <a href="javascript:popupDetailInline('${inlineCounter}');"><img > src='<@ofbizContentUrl>${contentPathPrefix?if_exists}${productLargeImageUrl?if_exists}</@ofbizContentUrl>' > name='mainImage${inlineCounter}' vspace='5' hspace='5' border='0' > width='100' align='left'></a> > + </#if> > + </td> > + <td align="right" valign="top" width="100%"> > + <#-- > <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2> --> > + <#assign inStock = true> > + <#if product.isVirtual?if_exists?upper_case == "Y"> > + <#if product.virtualVariantMethodEnum?if_exists == > "VV_FEATURETREE" && featureLists?has_content> > + <#list featureLists as featureList> > + <#list featureList as feature> > + <#if feature_index == 0> > + <div>${feature.description}: <select > id="FT${inlineCounter}${feature.productFeatureTypeId}" > name="FT${inlineCounter}${feature.productFeatureTypeId}" > onChange="javascript:checkRadioButtoninline('${inlineCounter}', > '${product.productId}');"> > + <option value="select" selected="selected"> select > option </option> > + <#else> > + <option > value="${feature.productFeatureId}">${feature.description} <#if > feature.price?exists>(+ <@ofbizCurrency amount=feature.price?string > isoCode=feature.currencyUomId/>)</#if></option> > + </#if> > + </#list> > + </select> > + </div> > + </#list> > + <input type="hidden" name="product_id${inlineCounter}" > value="${product.productId}"/> > + <input type="hidden" name="add_product_id${inlineCounter}" > value="NULL"/> > + </#if> > + <#if !product.virtualVariantMethodEnum?exists || > product.virtualVariantMethodEnum == "VV_VARIANTTREE"> > + <#if variantTree?exists && (variantTree.size() > 0)> > + <#list featureSet as currentType> > + <div> > + <select name="FT${inlineCounter}${currentType}" > onchange="javascript:getListInline('${inlineCounter}', this.name, > (this.selectedIndex-1), 1);"> > + <option>${featureTypes.get(currentType)}</option> > + </select> > + </div> > + </#list> > + <input type="hidden" name="product_id${inlineCounter}" > value="${product.productId}"/> > + <input type="hidden" name="add_product_id${inlineCounter}" > value="NULL"/> > + <div> > + <b><span id="product_id_display${inlineCounter}"> > </span></b> > + <b><div id="variant_price_display${inlineCounter}"> > </div></b> > + </div> > + <#else> > + <input type="hidden" name="product_id${inlineCounter}" > value="${product.productId}"/> > + <input type="hidden" name="add_product_id${inlineCounter}" > value="NULL"/> > + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> > + <#assign inStock = false> > + </#if> > + </#if> > + <#else> > + <input type="hidden" name="product_id${inlineCounter}" > value="${product.productId}"/> > + <input type="hidden" name="add_product_id${inlineCounter}" > value="${product.productId}"/> > + <#assign isStoreInventoryNotAvailable = > !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, > product, 1.0?double))> > + <#assign isStoreInventoryRequired = > Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, > product)> > + <#if isStoreInventoryNotAvailable> > + <#if isStoreInventoryRequired> > + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> > + <#assign inStock = false> > + <#else> > + <div><b>${product.inventoryMessage?if_exists}</b></div> > + </#if> > + </#if> > + </#if> > + </td></tr> > + <tr><td COLSPAN="2" align="right"> > + <#-- check to see if introductionDate hasnt passed yet --> > + <#if product.introductionDate?exists && > nowTimestamp.before(product.introductionDate)> > + <p> </p> > + <div style="color: > red;">${uiLabelMap.ProductProductNotYetMadeAvailable}.</div> > + <#-- check to see if salesDiscontinuationDate has passed --> > + <#elseif product.salesDiscontinuationDate?exists && > nowTimestamp.after(product.salesDiscontinuationDate)> > + <div style="color: > red;">${uiLabelMap.ProductProductNoLongerAvailable}.</div> > + <#-- check to see if the product requires inventory check and has > inventory --> > + <#elseif product.virtualVariantMethodEnum?if_exists != > "VV_FEATURETREE"> > + <#if inStock> > + <#if product.requireAmount?default("N") == "Y"> > + <#assign hiddenStyle = "visible"> > + <#else> > + <#assign hiddenStyle = "hidden"> > + </#if> > + <div id="add_amount${inlineCounter}" class="${hiddenStyle}"> > + <span style="white-space: > nowrap;"><b>${uiLabelMap.CommonAmount}:</b></span> > + <input type="text" size="5" > name="add_amount${inlineCounter}" value=""/> > + </div> > + </#if> > + </#if> > + </td></tr> > + > + <tr><td COLSPAN="2" align="right"> > + <#if variantTree?exists && 0 < variantTree.size()> > + <script language="JavaScript" type="text/javascript">eval("list"+ > "${inlineCounter}" + "${featureOrderFirst}" + "()");</script> > + </#if> > + > + <#-- Swatches (virtual products only) . For now commented out, > before fixing a bug > + <#if variantSample?exists && 0 < variantSample.size()> > + <#assign imageKeys = variantSample.keySet()> > + <#assign imageMap = variantSample> > + <p> </p> > + <table cellspacing="0" cellpadding="0"> > + <tr> > + <#assign maxIndex = 7> > + <#assign indexer = 0> > + <#list imageKeys as key> > + <#assign swatchProduct = imageMap.get(key)> > + <#if swatchProduct?has_content && indexer < maxIndex> > + <#assign imageUrl = > Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(swatchProduct, > "SMALL_IMAGE_URL", request)?if_exists> > + <#if !imageUrl?has_content> > + <#assign imageUrl = > productContentWrapper.get("SMALL_IMAGE_URL")?if_exists> > + </#if> > + <#if !imageUrl?has_content> > + <#assign imageUrl = "/images/defaultImage.jpg"> > + </#if> > + <td align="center" valign="bottom"> > + <a href="javascript:getListInline('${inlineCounter}', > 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);"><img > src="<@ofbizContentUrl>${contentPathPrefix?if_exists}${imageUrl}</@ofbizContentUrl>" > border="0" width="60" height="60"></a> > + <br/> > + <a href="javascript:getListInline('${inlineCounter}', > 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);" > class="linktext">${key}</a> > + </td> > + </#if> > + <#assign indexer = indexer + 1> > + </#list> > + <#if (indexer > maxIndex)> > + <div><b>${uiLabelMap.ProductMoreOptions}</b></div> > + </#if> > + </tr> > + </table> > + </#if> --> > + </td> > + </tr> > +</table> > +</div> > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > > ------------------------------------------------------------------------------ > svn:keywords = Date Rev Author URL Id > > Propchange: > ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > > |
Administrator
|
Wooow, hard to find :D
Jacques From: "Vikas Mayur" <[hidden email]> > On Thu, Aug 14, 2008 at 2:07 PM, <[hidden email]> wrote: > >> Author: bibryam >> Date: Thu Aug 14 01:37:52 2008 >> New Revision: 685809 >> >> URL: http://svn.apache.org/viewvc?rev=685809&view=rev >> Log: >> Missed these files in my previous commit. >> >> Added: >> >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> (with props) >> >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> (with props) >> >> Added: >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy?rev=685809&view=auto >> >> ============================================================================== >> --- >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> (added) >> +++ >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> Thu Aug 14 01:37:52 2008 >> @@ -0,0 +1,311 @@ >> +/* >> + * 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.lang.*; >> +import java.util.*; >> +import java.text.NumberFormat; >> +import org.ofbiz.base.util.*; >> +import org.ofbiz.service.*; >> +import org.ofbiz.entity.*; >> +import org.ofbiz.entity.condition.*; >> +import org.ofbiz.entity.util.*; >> +import org.ofbiz.webapp.taglib.*; >> +import org.ofbiz.webapp.stats.VisitHandler; >> +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; >> +import org.ofbiz.product.catalog.*; >> +import org.ofbiz.product.category.*; >> +import org.ofbiz.product.product.ProductWorker; >> +import org.ofbiz.product.product.ProductContentWrapper; >> +import org.ofbiz.product.product.ProductSearch; >> +import org.ofbiz.product.product.ProductSearchSession; >> +import org.ofbiz.product.store.*; >> + >> +inlineProductId = request.getAttribute("inlineProductId"); >> +inlineCounter = request.getAttribute("inlineCounter"); >> +context.inlineCounter = inlineCounter; >> +context.inlineProductId = inlineProductId; >> + >> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >> +catalogName = CatalogWorker.getCatalogName(request); >> +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); >> + >> +if (inlineProductId) { >> + inlineProduct = delegator.findByPrimaryKeyCache("Product", [productId >> : inlineProductId]); >> + if (inlineProduct) { >> + context.product = inlineProduct; >> + contentWrapper = new ProductContentWrapper(inlineProduct, >> request); >> + context.put("title", contentWrapper.get("PRODUCT_NAME")); >> + context.put("metaDescription", contentWrapper.get("DESCRIPTION")); >> + productTemplate = product.detailScreen; >> + if (productTemplate) { >> + detailScreen = productTemplate; >> + } >> + } >> +} >> + >> +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); >> +if (templatePathPrefix) { >> + detailScreen = templatePathPrefix + detailScreen; >> +} >> +context.detailScreen = detailScreen; >> + >> +String buildNext(Map map, List order, String current, String prefix, Map >> featureTypes) { >> + def ct = 0; >> + def buf = new StringBuffer(); >> + buf.append("function listFT" + inlineCounter + current + prefix + "() >> { "); >> + buf.append("document.forms[\"configform\"].elements[\"FT" + >> inlineCounter + current + "\"].options.length = 1;"); >> + buf.append("document.forms[\"configform\"].elements[\"FT" + >> inlineCounter + current + "\"].options[0] = new Option(\"" + >> featureTypes[current] + "\",\"\",true,true);"); >> + map.each { key, value -> >> + def optValue = null; >> + >> + if (order.indexOf(current) == (order.size()-1)) { >> + optValue = value.iterator().next(); >> + } else { >> + optValue = prefix + "_" + ct; >> + } >> + >> + buf.append("document.forms[\"configform\"].elements[\"FT" + >> inlineCounter + current + "\"].options[" + (ct + 1) + "] = new Option(\"" + >> key + "\",\"" + optValue + "\");"); >> + ct++; >> + } >> + buf.append(" }"); >> + if (order.indexOf(current) < (order.size()-1)) { >> + ct = 0; >> + map.each { key, value -> >> + def nextOrder = order.get(order.indexOf(current)+1); >> + def newPrefix = prefix + "_" + ct; >> + buf.append(buildNext(value, order, nextOrder, newPrefix, >> featureTypes)); >> + ct++; >> + } >> + } >> + return buf.toString(); >> +} >> + >> +cart = ShoppingCartEvents.getCartObject(request); >> + >> +// set the content path prefix >> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >> +context.contentPathPrefix = contentPathPrefix; >> + >> +// get the product detail information >> +if (inlineProduct) { >> + inlineProductId = inlineProduct.productId; >> + productTypeId = inlineProduct.productTypeId; >> + featureTypes = [:]; >> + featureOrder = []; >> + >> + // make the productContentWrapper >> + productContentWrapper = new ProductContentWrapper(inlineProduct, >> request); >> + context.productContentWrapper = productContentWrapper; >> + >> + // get the main detail image (virtual or single product) >> + mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL"); >> + if (mainDetailImage) { >> + mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + >> mainDetailImage; >> + mainDetailImageUrl = >> URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8"); >> + context.mainDetailImageUrl = mainDetailImageUrl; >> + } >> + >> + >> + // get the product price >> + webSiteId = CatalogWorker.getWebSiteId(request); >> + autoUserLogin = request.getSession().getAttribute("autoUserLogin"); >> + if (cart.isSalesOrder()) { >> + // sales order: run the "calculateProductPrice" service >> + priceContext = [product : inlineProduct, prodCatalogId : >> currentCatalogId, >> + currencyUomId : cart.getCurrency(), autoUserLogin : >> autoUserLogin]; >> + priceContext.webSiteId = webSiteId; >> + priceContext.productStoreId = productStoreId; >> + priceContext.checkIncludeVat = "Y"; >> + priceContext.agreementId = cart.getAgreementId(); >> + priceContext.partyId = cart.getPartyId(); // IMPORTANT: must put >> this in, or price will be calculated for the CSR instead of the customer >> + priceMap = dispatcher.runSync("calculateProductPrice", >> priceContext); >> + context.priceMap = priceMap; >> + } else { >> + // purchase order: run the "calculatePurchasePrice" service >> + priceContext = [product : inlineProduct, currencyUomId : >> cart.getCurrency(), >> + partyId : cart.getPartyId(), userLogin : userLogin]; >> + priceMap = dispatcher.runSync("calculatePurchasePrice", >> priceContext); >> + context.priceMap = priceMap; >> + } >> + >> + >> + context.variantTree = null; >> + context.variantTreeSize = null; >> + context.variantSample = null; >> + context.variantSampleKeys = null; >> + context.variantSampleSize = null; >> + if ("Y".equals(inlineProduct.isVirtual)) { >> + if >> ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod(delegator, >> inlineProductId))) { >> + context.featureLists = >> ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct); >> + } else { >> + featureMap = dispatcher.runSync("getProductFeatureSet", >> [productId : inlineProductId]); >> + featureSet = featureMap.featureSet; >> + if (featureSet) { >> + variantTreeMap = >> dispatcher.runSync("getProductVariantTree", [productId : inlineProductId, >> featureOrder : featureSet, productStoreId : productStoreId]); >> + variantTree = variantTreeMap.variantTree; >> + imageMap = variantTreeMap.variantSample; >> + virtualVariant = variantTreeMap.virtualVariant; >> + context.virtualVariant = virtualVariant; >> + if (variantTree) { >> + context.variantTree = variantTree; >> + context.variantTreeSize = variantTree.size(); >> + } >> + if (imageMap) { >> + context.variantSample = imageMap; >> + context.variantSampleKeys = imageMap.keySet(); >> + context.variantSampleSize = imageMap.size(); >> + } >> + context.featureSet = featureSet; >> + >> + if (variantTree) { >> + featureOrder = new LinkedList(featureSet); >> + featureOrder.each { featureKey -> >> + featureValue = >> delegator.findByPrimaryKeyCache("ProductFeatureType", [productFeatureTypeId >> : featureKey]); >> + fValue = featureValue.get("description") ?: >> featureValue.productFeatureTypeId; >> + featureTypes[featureKey] = fValue; >> + } >> + } >> + context.featureTypes = featureTypes; >> + context.featureOrder = featureOrder; >> + if (featureOrder) { >> + context.featureOrderFirst = featureOrder[0]; >> + } >> + >> + if (variantTree && imageMap) { >> + jsBuf = new StringBuffer(); >> + jsBuf.append("<script language=\"JavaScript\">"); >> + jsBuf.append("var DET" + inlineCounter + "= new >> Array(" + variantTree.size() + ");"); >> + jsBuf.append("var IMG" + inlineCounter + " = new >> Array(" + variantTree.size() + ");"); >> + jsBuf.append("var OPT" + inlineCounter + " = new >> Array(" + featureOrder.size() + ");"); >> + jsBuf.append("var VIR" + inlineCounter + " = new >> Array(" + virtualVariant.size() + ");"); >> + jsBuf.append("var detailImageUrl" + inlineCounter + " >> = null;"); >> + featureOrder.eachWithIndex { feature, i -> >> + jsBuf.append("OPT" + inlineCounter + "[" + i + "] >> = \"FT" + inlineCounter + feature + "\";"); >> + } >> + virtualVariant.eachWithIndex { variant, i -> >> + jsBuf.append("VIR" + inlineCounter + "[" + i + "] >> = \"" + variant + "\";"); >> + } >> + >> + // build the top level >> + topLevelName = featureOrder[0]; >> + jsBuf.append("function list" + inlineCounter + >> topLevelName + "() {"); >> + >> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter >> + topLevelName + "\"].options.length = 1;"); >> + >> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter >> + topLevelName + "\"].options[0] = new Option(\"" + >> featureTypes[topLevelName] + "\",\"\",true,true);"); >> + if (variantTree) { >> + featureOrder.each { featureKey -> >> + >> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter >> + featureKey + "\"].options.length = 1;"); >> + } >> + firstDetailImage = null; >> + firstLargeImage = null; >> + counter = 0; >> + variantTree.each { key, value -> >> + opt = null; >> + if (featureOrder.size() == 1) { >> + opt = value.iterator().next(); >> + } else { >> + opt = counter as String; >> + } >> + // create the variant content wrapper >> + contentWrapper = new >> ProductContentWrapper(imageMap[key], request); >> + >> + // initial image paths >> + detailImage = >> contentWrapper.get("DETAIL_IMAGE_URL") ?: >> productContentWrapper.get("DETAIL_IMAGE_URL"); >> + largeImage = >> contentWrapper.get("LARGE_IMAGE_URL") ?: >> productContentWrapper.get("LARGE_IMAGE_URL"); >> + >> + // full image URLs >> + detailImageUrl = null; >> + largeImageUrl = null; >> + >> + // append the content prefix >> + if (detailImage) { >> + detailImageUrl = >> ContentUrlTag.getContentPrefix(request) + detailImage; >> + // base64 encode the image url for a >> little protection >> + detailImageUrl = >> URLEncoder.encode(Base64.base64Encode(detailImageUrl), "UTF-8"); >> + } >> + if (largeImage) { >> + largeImageUrl = >> ContentUrlTag.getContentPrefix(request) + largeImage; >> + } >> + >> + >> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + inlineCounter >> + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key + >> "\",\"" + opt + "\");"); >> + jsBuf.append("DET" + inlineCounter + "[" + >> counter + "] = \"" + detailImageUrl +"\";"); >> + jsBuf.append("IMG" + inlineCounter + "[" + >> counter + "] = \"" + largeImageUrl +"\";"); >> + >> + if (!firstDetailImage) { >> + firstDetailImage = detailImageUrl; >> + } >> + if (!firstLargeImage) { >> + firstLargeImage = largeImage; >> + } >> + counter++; >> + } >> + context.firstDetailImage = firstDetailImage; >> + context.firstLargeImage = firstLargeImage; >> + } >> + jsBuf.append("}"); >> + >> + // build dynamic lists >> + if (variantTree) { >> + variantTree.values().eachWithIndex { varTree, >> topLevelKeysCt -> >> + cnt = "" + topLevelKeysCt; >> + if (varTree instanceof Map) { >> + jsBuf.append(buildNext(varTree, >> featureOrder, featureOrder[1], cnt, featureTypes)); >> + } >> + } >> + } >> + >> + // make a list of variant sku with requireAmount >> + variantsRes = >> dispatcher.runSync("getAssociatedProducts", [productId : inlineProductId, >> type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : >> currentCatalogId]); >> + variants = variantsRes.assocProducts; >> + if (variants) { >> + amt = new StringBuffer(); >> + amt.append("function checkAmtReq" + inlineCounter >> + "(sku) { "); >> + // Create the javascript to return the price for >> each variant >> + variantPriceJS = new StringBuffer(); >> + variantPriceJS.append("function getVariantPrice" + >> inlineCounter + "(sku) { "); >> + // Format to apply the currency code to the >> variant price in the javascript >> + productStore = >> ProductStoreWorker.getProductStore(request); >> + localeString = productStore.defaultLocaleString; >> + if (localeString) { >> + locale = UtilMisc.parseLocale(localeString); >> + } >> + numberFormat = >> NumberFormat.getCurrencyInstance(locale); >> + variants.each { variantAssoc -> >> + variant = >> variantAssoc.getRelatedOne("AssocProduct"); >> + // Get the price for each variant. Reuse the >> priceContext already setup for virtual product above and replace the product >> + if (cart.isSalesOrder()) { >> + // sales order: run the >> "calculateProductPrice" service >> + priceContext.product = variant; >> + variantPriceMap = >> dispatcher.runSync("calculateProductPrice", priceContext); >> + } >> + amt.append(" if (sku == \"" + >> variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; >> "); >> + variantPriceJS.append(" if (sku == \"" + >> variant.productId + "\") return \"" + >> numberFormat.format(variantPriceMap.basePrice) + "\"; "); >> + } >> + amt.append(" } "); >> + variantPriceJS.append(" } "); >> + } >> + jsBuf.append(amt.toString()); >> + jsBuf.append(variantPriceJS.toString()); >> + jsBuf.append("</script>"); >> + >> + context.virtualJavaScript = jsBuf.toString(); >> + } >> + } >> + } >> + } >> +} >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> >> ------------------------------------------------------------------------------ >> svn:keywords = Date Rev Author URL Id >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >> >> ------------------------------------------------------------------------------ >> svn:mime-type = text/plain >> >> Added: >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl?rev=685809&view=auto >> >> ============================================================================== >> --- >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> (added) >> +++ >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> Thu Aug 14 01:37:52 2008 >> @@ -0,0 +1,389 @@ >> +<#-- >> +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. >> +--> >> + >> +${virtualJavaScript?if_exists} >> +<#assign addJavaScript = requestAttributes.addJavaScript/> >> +<#if (addJavaScript == 0)> >> +<script language="JavaScript" type="text/javascript"> >> + >> + function popupDetailInline(inlineCounter) { >> + var imageField = 'detailImage' + inlineCounter; >> + var defaultDetailImage = document.getElementById(imageField); >> + if (defaultDetailImage == null || defaultDetailImage == "null") { >> + defaultDetailImage = "_NONE_"; >> + } >> + var fieldName = 'detailImageUrl' + inlineCounter; >> + if (window[fieldName] == null || window[fieldName] == "null") { >> + window[fieldName] = defaultDetailImage; >> + } >> + >> + if (window[fieldName] == "_NONE_") { >> + alert("No detail image available to display."); >> + return; >> + } >> + popUp("<@ofbizUrl>detailImage?detail=" + window[fieldName] + >> "</@ofbizUrl>", 'detailImage', '400', '550'); >> + } >> + >> + function setAddProductIdInline(inlineCounter, name) { >> + var add_product_id = 'add_product_id' + inlineCounter; >> + var product_id_display = 'product_id_display' + inlineCounter; >> + document.configform[add_product_id].value = name; >> + if (name == '' || name == 'NULL' || isVirtualInline(inlineCounter, >> name) == true) { >> + //document.configform.quantity.disabled = true; >> + var elem = document.getElementById(product_id_display); >> + var txt = document.createTextNode(''); >> + if(elem.hasChildNodes()) { >> + elem.replaceChild(txt, elem.firstChild); >> + } else { >> + elem.appendChild(txt); >> + } >> + >> + checkOtion(inlineCounter); >> + } else { >> + //document.configform.quantity.disabled = false; >> + var elem = document.getElementById(product_id_display); >> + var txt = document.createTextNode(name); >> + if(elem.hasChildNodes()) { >> + elem.replaceChild(txt, elem.firstChild); >> + } else { >> + elem.appendChild(txt); >> + } >> + } >> + } >> + >> + function checkOtion(inlineCounter) { > > > I think it would be "checkOption" grammatically - but its not a big concern > :) > > - Vikas > > >> + var option = document.getElementById(inlineCounter.substring(0, >> inlineCounter.length - 2)); >> + if (option.checked) { >> + option.checked=false; >> + } >> + } >> + >> + function setVariantPriceInline(inlineCounter, sku) { >> + var variant_price_display = 'variant_price_display' + >> inlineCounter; >> + if (sku == '' || sku == 'NULL' || isVirtualInline(inlineCounter, >> sku) == true) { >> + var elem = document.getElementById(variant_price_display); >> + var txt = document.createTextNode(''); >> + if(elem.hasChildNodes()) { >> + elem.replaceChild(txt, elem.firstChild); >> + } else { >> + elem.appendChild(txt); >> + } >> + } >> + else { >> + var elem = document.getElementById(variant_price_display); >> + var functionName = 'getVariantPrice' + inlineCounter; >> + var price = window[functionName](sku); >> + var txt = document.createTextNode('+' + price); >> + if(elem.hasChildNodes()) { >> + elem.replaceChild(txt, elem.firstChild); >> + } else { >> + elem.appendChild(txt); >> + } >> + } >> + } >> + function isVirtualInline(inlineCounter, product) { >> + var isVirtual = false; >> + var fieldName = 'VIR' + inlineCounter; >> + <#if virtualJavaScript?exists> >> + for (i = 0; i < window[fieldName].length; i++) { >> + if (window[fieldName][i] == product) { >> + isVirtual = true; >> + } >> + } >> + </#if> >> + return isVirtual; >> + } >> + >> + function toggleAmtInline(inlineCounter, toggle) { >> + var fieldName = 'add_amount' + inlineCounter; >> + if (toggle == 'Y') { >> + changeObjectVisibility(fieldName, "visible"); >> + } >> + >> + if (toggle == 'N') { >> + changeObjectVisibility(fieldName, "hidden"); >> + } >> + } >> + >> + function findIndexInline(varname, name ) { >> + for (i = 0; i < window[varname].length; i++) { >> + if ( window[varname][i] == name) { >> + return i; >> + } >> + } >> + return -1; >> + } >> + >> + function checkOptionToggle(inlineCounter, disable) { >> + var index = inlineCounter.indexOf('_'); >> + var optionElementName = inlineCounter.substring(0,index); >> + var option = document.getElementById(optionElementName); >> + if ("true" == disable) { >> + option.disabled = true; >> + if (option.checked == true) { >> + option.checked == false; >> + } >> + } else { >> + //check all virtual product for the option >> + } >> + } >> + >> + function checkOptionVariants(optionName) { >> + var option = document.getElementById(optionName); >> + if (option.checked == false) { >> + return false; >> + } >> + >> + var fieldName = "add_product_id" + optionName + "_"; >> + var index = 15 + optionName.toString().length; >> + var cform = document.forms["configform"]; >> + var len = cform.elements.length; >> + for (var i = 0; i < len; i++) { >> + var element = cform.elements[i]; >> + if (element.name.substring(0, index) == fieldName) { >> + if (element.value == '' || element.value == 'NULL') { >> + option.checked = false; >> + alert('Please select all features first'); >> + return false; >> + } >> + } >> + } >> + } >> + >> + function getListInline(inlineCounter, name, index, src) { >> + currentFeatureIndex = findIndexInline('OPT'+inlineCounter, name); >> + >> + if (currentFeatureIndex == 0) { >> + // set the images for the first selection >> + if ([index] != null) { >> + if (document.images['mainImage'+ inlineCounter] != null) { >> + document.images['mainImage'+ inlineCounter].src = >> window['IMG'+ inlineCounter][index]; >> + window['detailImageUrl'+ inlineCounter] = >> window['DET'+ inlineCounter][index]; >> + } >> + } >> + >> + // set the drop down index for swatch selection >> + document.forms["configform"].elements[name].selectedIndex = >> (index*1)+1; >> + } >> + >> + if (currentFeatureIndex < (window['OPT'+ inlineCounter].length-1)) >> { >> + // eval the next list if there are more >> + var selectedValue = >> document.forms["configform"].elements[name].options[(index*1)+1].value; >> + if (index == -1) { >> + var featureOrderFirst = window['OPT'+ >> inlineCounter][(currentFeatureIndex)].toString(); >> + var length = featureOrderFirst.length; >> + featureOrderFirst = featureOrderFirst.substring(2, >> length); >> + var Variable1 = eval("list" + featureOrderFirst + "()"); >> + } else { >> + var Variable1 = eval("list" + window['OPT'+ >> inlineCounter][(currentFeatureIndex+1)] + selectedValue + "()"); >> + } >> + >> + // set the product ID to NULL to trigger the alerts >> + setAddProductIdInline(inlineCounter, 'NULL'); >> + >> + // set the variant price to NULL >> + setVariantPriceInline(inlineCounter, 'NULL'); >> + >> + //checkOptionToggle(inlineCounter, 'false'); >> + } else { >> + // this is the final selection -- locate the selected index of >> the last selection >> + var indexSelected = >> document.forms["configform"].elements[name].selectedIndex; >> + >> + // using the selected index locate the sku >> + var sku = >> document.forms["configform"].elements[name].options[indexSelected].value; >> + >> + // set the product ID >> + setAddProductIdInline(inlineCounter, sku); >> + >> + // set the variant price >> + setVariantPriceInline(inlineCounter, sku); >> + >> + // check for amount box >> + var functionName = 'checkAmtReq' + inlineCounter; >> + toggleAmtInline(inlineCounter, window[functionName](sku)); >> + >> + //checkOptionToggle(inlineCounter, 'true'); >> + } >> + } >> + >> + >> + </script> >> +</#if> >> + >> +<#assign addedFeatureTreeJavaScript = >> requestAttributes.addedFeatureTreeJavaScript?default("N")/> >> +<#if product.virtualVariantMethodEnum?if_exists == "VV_FEATURETREE" && >> featureLists?has_content && ("N" == addedFeatureTreeJavaScript)> >> + ${setRequestAttribute("addedFeatureTreeJavaScript", "Y")} >> + <script language="JavaScript" type="text/javascript"> >> + function checkRadioButtoninline(inlineCounter, productId) { >> + var add_product_id = 'add_product_id' + inlineCounter; >> + <#list featureLists as featureList> >> + <#list featureList as feature> >> + <#if feature_index == 0> >> + var myList = document.getElementById("FT" >> +inlineCounter + "${feature.productFeatureTypeId}"); >> + if (myList.options[0].selected == true) { >> + document.configform[add_product_id].value = >> 'NULL'; >> + return; >> + } >> + <#break> >> + </#if> >> + </#list> >> + </#list> >> + document.configform[add_product_id].value = productId; >> + } >> + </script> >> +</#if> >> + >> + >> +<#assign price = priceMap?if_exists/> >> +<div id="inlineproductdetail${inlineCounter}"> >> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> >> + <tr> >> + <td align="left" valign="top" width="0"> >> + <#assign productLargeImageUrl = >> productContentWrapper.get("LARGE_IMAGE_URL")?if_exists> >> + <#if firstLargeImage?has_content> >> + <#assign productLargeImageUrl = firstLargeImage> >> + </#if> >> + <#if productLargeImageUrl?has_content> >> + <input type="hidden" name="detailImage${inlineCounter}" >> value="${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}"/> >> + <a href="javascript:popupDetailInline('${inlineCounter}');"><img >> src='<@ofbizContentUrl>${contentPathPrefix?if_exists}${productLargeImageUrl?if_exists}</@ofbizContentUrl>' >> name='mainImage${inlineCounter}' vspace='5' hspace='5' border='0' >> width='100' align='left'></a> >> + </#if> >> + </td> >> + <td align="right" valign="top" width="100%"> >> + <#-- >> <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2> --> >> + <#assign inStock = true> >> + <#if product.isVirtual?if_exists?upper_case == "Y"> >> + <#if product.virtualVariantMethodEnum?if_exists == >> "VV_FEATURETREE" && featureLists?has_content> >> + <#list featureLists as featureList> >> + <#list featureList as feature> >> + <#if feature_index == 0> >> + <div>${feature.description}: <select >> id="FT${inlineCounter}${feature.productFeatureTypeId}" >> name="FT${inlineCounter}${feature.productFeatureTypeId}" >> onChange="javascript:checkRadioButtoninline('${inlineCounter}', >> '${product.productId}');"> >> + <option value="select" selected="selected"> select >> option </option> >> + <#else> >> + <option >> value="${feature.productFeatureId}">${feature.description} <#if >> feature.price?exists>(+ <@ofbizCurrency amount=feature.price?string >> isoCode=feature.currencyUomId/>)</#if></option> >> + </#if> >> + </#list> >> + </select> >> + </div> >> + </#list> >> + <input type="hidden" name="product_id${inlineCounter}" >> value="${product.productId}"/> >> + <input type="hidden" name="add_product_id${inlineCounter}" >> value="NULL"/> >> + </#if> >> + <#if !product.virtualVariantMethodEnum?exists || >> product.virtualVariantMethodEnum == "VV_VARIANTTREE"> >> + <#if variantTree?exists && (variantTree.size() > 0)> >> + <#list featureSet as currentType> >> + <div> >> + <select name="FT${inlineCounter}${currentType}" >> onchange="javascript:getListInline('${inlineCounter}', this.name, >> (this.selectedIndex-1), 1);"> >> + <option>${featureTypes.get(currentType)}</option> >> + </select> >> + </div> >> + </#list> >> + <input type="hidden" name="product_id${inlineCounter}" >> value="${product.productId}"/> >> + <input type="hidden" name="add_product_id${inlineCounter}" >> value="NULL"/> >> + <div> >> + <b><span id="product_id_display${inlineCounter}"> >> </span></b> >> + <b><div id="variant_price_display${inlineCounter}"> >> </div></b> >> + </div> >> + <#else> >> + <input type="hidden" name="product_id${inlineCounter}" >> value="${product.productId}"/> >> + <input type="hidden" name="add_product_id${inlineCounter}" >> value="NULL"/> >> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >> + <#assign inStock = false> >> + </#if> >> + </#if> >> + <#else> >> + <input type="hidden" name="product_id${inlineCounter}" >> value="${product.productId}"/> >> + <input type="hidden" name="add_product_id${inlineCounter}" >> value="${product.productId}"/> >> + <#assign isStoreInventoryNotAvailable = >> !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, >> product, 1.0?double))> >> + <#assign isStoreInventoryRequired = >> Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, >> product)> >> + <#if isStoreInventoryNotAvailable> >> + <#if isStoreInventoryRequired> >> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >> + <#assign inStock = false> >> + <#else> >> + <div><b>${product.inventoryMessage?if_exists}</b></div> >> + </#if> >> + </#if> >> + </#if> >> + </td></tr> >> + <tr><td COLSPAN="2" align="right"> >> + <#-- check to see if introductionDate hasnt passed yet --> >> + <#if product.introductionDate?exists && >> nowTimestamp.before(product.introductionDate)> >> + <p> </p> >> + <div style="color: >> red;">${uiLabelMap.ProductProductNotYetMadeAvailable}.</div> >> + <#-- check to see if salesDiscontinuationDate has passed --> >> + <#elseif product.salesDiscontinuationDate?exists && >> nowTimestamp.after(product.salesDiscontinuationDate)> >> + <div style="color: >> red;">${uiLabelMap.ProductProductNoLongerAvailable}.</div> >> + <#-- check to see if the product requires inventory check and has >> inventory --> >> + <#elseif product.virtualVariantMethodEnum?if_exists != >> "VV_FEATURETREE"> >> + <#if inStock> >> + <#if product.requireAmount?default("N") == "Y"> >> + <#assign hiddenStyle = "visible"> >> + <#else> >> + <#assign hiddenStyle = "hidden"> >> + </#if> >> + <div id="add_amount${inlineCounter}" class="${hiddenStyle}"> >> + <span style="white-space: >> nowrap;"><b>${uiLabelMap.CommonAmount}:</b></span> >> + <input type="text" size="5" >> name="add_amount${inlineCounter}" value=""/> >> + </div> >> + </#if> >> + </#if> >> + </td></tr> >> + >> + <tr><td COLSPAN="2" align="right"> >> + <#if variantTree?exists && 0 < variantTree.size()> >> + <script language="JavaScript" type="text/javascript">eval("list"+ >> "${inlineCounter}" + "${featureOrderFirst}" + "()");</script> >> + </#if> >> + >> + <#-- Swatches (virtual products only) . For now commented out, >> before fixing a bug >> + <#if variantSample?exists && 0 < variantSample.size()> >> + <#assign imageKeys = variantSample.keySet()> >> + <#assign imageMap = variantSample> >> + <p> </p> >> + <table cellspacing="0" cellpadding="0"> >> + <tr> >> + <#assign maxIndex = 7> >> + <#assign indexer = 0> >> + <#list imageKeys as key> >> + <#assign swatchProduct = imageMap.get(key)> >> + <#if swatchProduct?has_content && indexer < maxIndex> >> + <#assign imageUrl = >> Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(swatchProduct, >> "SMALL_IMAGE_URL", request)?if_exists> >> + <#if !imageUrl?has_content> >> + <#assign imageUrl = >> productContentWrapper.get("SMALL_IMAGE_URL")?if_exists> >> + </#if> >> + <#if !imageUrl?has_content> >> + <#assign imageUrl = "/images/defaultImage.jpg"> >> + </#if> >> + <td align="center" valign="bottom"> >> + <a href="javascript:getListInline('${inlineCounter}', >> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);"><img >> src="<@ofbizContentUrl>${contentPathPrefix?if_exists}${imageUrl}</@ofbizContentUrl>" >> border="0" width="60" height="60"></a> >> + <br/> >> + <a href="javascript:getListInline('${inlineCounter}', >> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);" >> class="linktext">${key}</a> >> + </td> >> + </#if> >> + <#assign indexer = indexer + 1> >> + </#list> >> + <#if (indexer > maxIndex)> >> + <div><b>${uiLabelMap.ProductMoreOptions}</b></div> >> + </#if> >> + </tr> >> + </table> >> + </#if> --> >> + </td> >> + </tr> >> +</table> >> +</div> >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> >> ------------------------------------------------------------------------------ >> svn:eol-style = native >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> >> ------------------------------------------------------------------------------ >> svn:keywords = Date Rev Author URL Id >> >> Propchange: >> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >> >> ------------------------------------------------------------------------------ >> svn:mime-type = text/plain >> >> >> > |
Jacques, Do you know Vikas has 10 Eyes :D ?
-- Ashish Vijaywargiya Indore (M.P), India http://en.wikipedia.org/wiki/Indore On Thu, Aug 21, 2008 at 4:05 PM, Jacques Le Roux < [hidden email]> wrote: > Wooow, hard to find :D > > Jacques > > From: "Vikas Mayur" <[hidden email]> > > On Thu, Aug 14, 2008 at 2:07 PM, <[hidden email]> wrote: >> >> Author: bibryam >>> Date: Thu Aug 14 01:37:52 2008 >>> New Revision: 685809 >>> >>> URL: http://svn.apache.org/viewvc?rev=685809&view=rev >>> Log: >>> Missed these files in my previous commit. >>> >>> Added: >>> >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> (with props) >>> >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> (with props) >>> >>> Added: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> URL: >>> >>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy?rev=685809&view=auto >>> >>> >>> ============================================================================== >>> --- >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> (added) >>> +++ >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> Thu Aug 14 01:37:52 2008 >>> @@ -0,0 +1,311 @@ >>> +/* >>> + * 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.lang.*; >>> +import java.util.*; >>> +import java.text.NumberFormat; >>> +import org.ofbiz.base.util.*; >>> +import org.ofbiz.service.*; >>> +import org.ofbiz.entity.*; >>> +import org.ofbiz.entity.condition.*; >>> +import org.ofbiz.entity.util.*; >>> +import org.ofbiz.webapp.taglib.*; >>> +import org.ofbiz.webapp.stats.VisitHandler; >>> +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; >>> +import org.ofbiz.product.catalog.*; >>> +import org.ofbiz.product.category.*; >>> +import org.ofbiz.product.product.ProductWorker; >>> +import org.ofbiz.product.product.ProductContentWrapper; >>> +import org.ofbiz.product.product.ProductSearch; >>> +import org.ofbiz.product.product.ProductSearchSession; >>> +import org.ofbiz.product.store.*; >>> + >>> +inlineProductId = request.getAttribute("inlineProductId"); >>> +inlineCounter = request.getAttribute("inlineCounter"); >>> +context.inlineCounter = inlineCounter; >>> +context.inlineProductId = inlineProductId; >>> + >>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>> +catalogName = CatalogWorker.getCatalogName(request); >>> +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); >>> + >>> +if (inlineProductId) { >>> + inlineProduct = delegator.findByPrimaryKeyCache("Product", >>> [productId >>> : inlineProductId]); >>> + if (inlineProduct) { >>> + context.product = inlineProduct; >>> + contentWrapper = new ProductContentWrapper(inlineProduct, >>> request); >>> + context.put("title", contentWrapper.get("PRODUCT_NAME")); >>> + context.put("metaDescription", >>> contentWrapper.get("DESCRIPTION")); >>> + productTemplate = product.detailScreen; >>> + if (productTemplate) { >>> + detailScreen = productTemplate; >>> + } >>> + } >>> +} >>> + >>> +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); >>> +if (templatePathPrefix) { >>> + detailScreen = templatePathPrefix + detailScreen; >>> +} >>> +context.detailScreen = detailScreen; >>> + >>> +String buildNext(Map map, List order, String current, String prefix, Map >>> featureTypes) { >>> + def ct = 0; >>> + def buf = new StringBuffer(); >>> + buf.append("function listFT" + inlineCounter + current + prefix + >>> "() >>> { "); >>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter + current + "\"].options.length = 1;"); >>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter + current + "\"].options[0] = new Option(\"" + >>> featureTypes[current] + "\",\"\",true,true);"); >>> + map.each { key, value -> >>> + def optValue = null; >>> + >>> + if (order.indexOf(current) == (order.size()-1)) { >>> + optValue = value.iterator().next(); >>> + } else { >>> + optValue = prefix + "_" + ct; >>> + } >>> + >>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter + current + "\"].options[" + (ct + 1) + "] = new Option(\"" >>> + >>> key + "\",\"" + optValue + "\");"); >>> + ct++; >>> + } >>> + buf.append(" }"); >>> + if (order.indexOf(current) < (order.size()-1)) { >>> + ct = 0; >>> + map.each { key, value -> >>> + def nextOrder = order.get(order.indexOf(current)+1); >>> + def newPrefix = prefix + "_" + ct; >>> + buf.append(buildNext(value, order, nextOrder, newPrefix, >>> featureTypes)); >>> + ct++; >>> + } >>> + } >>> + return buf.toString(); >>> +} >>> + >>> +cart = ShoppingCartEvents.getCartObject(request); >>> + >>> +// set the content path prefix >>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>> +context.contentPathPrefix = contentPathPrefix; >>> + >>> +// get the product detail information >>> +if (inlineProduct) { >>> + inlineProductId = inlineProduct.productId; >>> + productTypeId = inlineProduct.productTypeId; >>> + featureTypes = [:]; >>> + featureOrder = []; >>> + >>> + // make the productContentWrapper >>> + productContentWrapper = new ProductContentWrapper(inlineProduct, >>> request); >>> + context.productContentWrapper = productContentWrapper; >>> + >>> + // get the main detail image (virtual or single product) >>> + mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL"); >>> + if (mainDetailImage) { >>> + mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + >>> mainDetailImage; >>> + mainDetailImageUrl = >>> URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8"); >>> + context.mainDetailImageUrl = mainDetailImageUrl; >>> + } >>> + >>> + >>> + // get the product price >>> + webSiteId = CatalogWorker.getWebSiteId(request); >>> + autoUserLogin = request.getSession().getAttribute("autoUserLogin"); >>> + if (cart.isSalesOrder()) { >>> + // sales order: run the "calculateProductPrice" service >>> + priceContext = [product : inlineProduct, prodCatalogId : >>> currentCatalogId, >>> + currencyUomId : cart.getCurrency(), autoUserLogin : >>> autoUserLogin]; >>> + priceContext.webSiteId = webSiteId; >>> + priceContext.productStoreId = productStoreId; >>> + priceContext.checkIncludeVat = "Y"; >>> + priceContext.agreementId = cart.getAgreementId(); >>> + priceContext.partyId = cart.getPartyId(); // IMPORTANT: must >>> put >>> this in, or price will be calculated for the CSR instead of the customer >>> + priceMap = dispatcher.runSync("calculateProductPrice", >>> priceContext); >>> + context.priceMap = priceMap; >>> + } else { >>> + // purchase order: run the "calculatePurchasePrice" service >>> + priceContext = [product : inlineProduct, currencyUomId : >>> cart.getCurrency(), >>> + partyId : cart.getPartyId(), userLogin : userLogin]; >>> + priceMap = dispatcher.runSync("calculatePurchasePrice", >>> priceContext); >>> + context.priceMap = priceMap; >>> + } >>> + >>> + >>> + context.variantTree = null; >>> + context.variantTreeSize = null; >>> + context.variantSample = null; >>> + context.variantSampleKeys = null; >>> + context.variantSampleSize = null; >>> + if ("Y".equals(inlineProduct.isVirtual)) { >>> + if >>> >>> ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod(delegator, >>> inlineProductId))) { >>> + context.featureLists = >>> ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct); >>> + } else { >>> + featureMap = dispatcher.runSync("getProductFeatureSet", >>> [productId : inlineProductId]); >>> + featureSet = featureMap.featureSet; >>> + if (featureSet) { >>> + variantTreeMap = >>> dispatcher.runSync("getProductVariantTree", [productId : inlineProductId, >>> featureOrder : featureSet, productStoreId : productStoreId]); >>> + variantTree = variantTreeMap.variantTree; >>> + imageMap = variantTreeMap.variantSample; >>> + virtualVariant = variantTreeMap.virtualVariant; >>> + context.virtualVariant = virtualVariant; >>> + if (variantTree) { >>> + context.variantTree = variantTree; >>> + context.variantTreeSize = variantTree.size(); >>> + } >>> + if (imageMap) { >>> + context.variantSample = imageMap; >>> + context.variantSampleKeys = imageMap.keySet(); >>> + context.variantSampleSize = imageMap.size(); >>> + } >>> + context.featureSet = featureSet; >>> + >>> + if (variantTree) { >>> + featureOrder = new LinkedList(featureSet); >>> + featureOrder.each { featureKey -> >>> + featureValue = >>> delegator.findByPrimaryKeyCache("ProductFeatureType", >>> [productFeatureTypeId >>> : featureKey]); >>> + fValue = featureValue.get("description") ?: >>> featureValue.productFeatureTypeId; >>> + featureTypes[featureKey] = fValue; >>> + } >>> + } >>> + context.featureTypes = featureTypes; >>> + context.featureOrder = featureOrder; >>> + if (featureOrder) { >>> + context.featureOrderFirst = featureOrder[0]; >>> + } >>> + >>> + if (variantTree && imageMap) { >>> + jsBuf = new StringBuffer(); >>> + jsBuf.append("<script language=\"JavaScript\">"); >>> + jsBuf.append("var DET" + inlineCounter + "= new >>> Array(" + variantTree.size() + ");"); >>> + jsBuf.append("var IMG" + inlineCounter + " = new >>> Array(" + variantTree.size() + ");"); >>> + jsBuf.append("var OPT" + inlineCounter + " = new >>> Array(" + featureOrder.size() + ");"); >>> + jsBuf.append("var VIR" + inlineCounter + " = new >>> Array(" + virtualVariant.size() + ");"); >>> + jsBuf.append("var detailImageUrl" + inlineCounter + >>> " >>> = null;"); >>> + featureOrder.eachWithIndex { feature, i -> >>> + jsBuf.append("OPT" + inlineCounter + "[" + i + >>> "] >>> = \"FT" + inlineCounter + feature + "\";"); >>> + } >>> + virtualVariant.eachWithIndex { variant, i -> >>> + jsBuf.append("VIR" + inlineCounter + "[" + i + >>> "] >>> = \"" + variant + "\";"); >>> + } >>> + >>> + // build the top level >>> + topLevelName = featureOrder[0]; >>> + jsBuf.append("function list" + inlineCounter + >>> topLevelName + "() {"); >>> + >>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter >>> + topLevelName + "\"].options.length = 1;"); >>> + >>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter >>> + topLevelName + "\"].options[0] = new Option(\"" + >>> featureTypes[topLevelName] + "\",\"\",true,true);"); >>> + if (variantTree) { >>> + featureOrder.each { featureKey -> >>> + >>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter >>> + featureKey + "\"].options.length = 1;"); >>> + } >>> + firstDetailImage = null; >>> + firstLargeImage = null; >>> + counter = 0; >>> + variantTree.each { key, value -> >>> + opt = null; >>> + if (featureOrder.size() == 1) { >>> + opt = value.iterator().next(); >>> + } else { >>> + opt = counter as String; >>> + } >>> + // create the variant content wrapper >>> + contentWrapper = new >>> ProductContentWrapper(imageMap[key], request); >>> + >>> + // initial image paths >>> + detailImage = >>> contentWrapper.get("DETAIL_IMAGE_URL") ?: >>> productContentWrapper.get("DETAIL_IMAGE_URL"); >>> + largeImage = >>> contentWrapper.get("LARGE_IMAGE_URL") ?: >>> productContentWrapper.get("LARGE_IMAGE_URL"); >>> + >>> + // full image URLs >>> + detailImageUrl = null; >>> + largeImageUrl = null; >>> + >>> + // append the content prefix >>> + if (detailImage) { >>> + detailImageUrl = >>> ContentUrlTag.getContentPrefix(request) + detailImage; >>> + // base64 encode the image url for a >>> little protection >>> + detailImageUrl = >>> URLEncoder.encode(Base64.base64Encode(detailImageUrl), "UTF-8"); >>> + } >>> + if (largeImage) { >>> + largeImageUrl = >>> ContentUrlTag.getContentPrefix(request) + largeImage; >>> + } >>> + >>> + >>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>> inlineCounter >>> + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key >>> + >>> "\",\"" + opt + "\");"); >>> + jsBuf.append("DET" + inlineCounter + "[" + >>> counter + "] = \"" + detailImageUrl +"\";"); >>> + jsBuf.append("IMG" + inlineCounter + "[" + >>> counter + "] = \"" + largeImageUrl +"\";"); >>> + >>> + if (!firstDetailImage) { >>> + firstDetailImage = detailImageUrl; >>> + } >>> + if (!firstLargeImage) { >>> + firstLargeImage = largeImage; >>> + } >>> + counter++; >>> + } >>> + context.firstDetailImage = firstDetailImage; >>> + context.firstLargeImage = firstLargeImage; >>> + } >>> + jsBuf.append("}"); >>> + >>> + // build dynamic lists >>> + if (variantTree) { >>> + variantTree.values().eachWithIndex { varTree, >>> topLevelKeysCt -> >>> + cnt = "" + topLevelKeysCt; >>> + if (varTree instanceof Map) { >>> + jsBuf.append(buildNext(varTree, >>> featureOrder, featureOrder[1], cnt, featureTypes)); >>> + } >>> + } >>> + } >>> + >>> + // make a list of variant sku with requireAmount >>> + variantsRes = >>> dispatcher.runSync("getAssociatedProducts", [productId : inlineProductId, >>> type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : >>> currentCatalogId]); >>> + variants = variantsRes.assocProducts; >>> + if (variants) { >>> + amt = new StringBuffer(); >>> + amt.append("function checkAmtReq" + >>> inlineCounter >>> + "(sku) { "); >>> + // Create the javascript to return the price for >>> each variant >>> + variantPriceJS = new StringBuffer(); >>> + variantPriceJS.append("function getVariantPrice" >>> + >>> inlineCounter + "(sku) { "); >>> + // Format to apply the currency code to the >>> variant price in the javascript >>> + productStore = >>> ProductStoreWorker.getProductStore(request); >>> + localeString = productStore.defaultLocaleString; >>> + if (localeString) { >>> + locale = UtilMisc.parseLocale(localeString); >>> + } >>> + numberFormat = >>> NumberFormat.getCurrencyInstance(locale); >>> + variants.each { variantAssoc -> >>> + variant = >>> variantAssoc.getRelatedOne("AssocProduct"); >>> + // Get the price for each variant. Reuse the >>> priceContext already setup for virtual product above and replace the >>> product >>> + if (cart.isSalesOrder()) { >>> + // sales order: run the >>> "calculateProductPrice" service >>> + priceContext.product = variant; >>> + variantPriceMap = >>> dispatcher.runSync("calculateProductPrice", priceContext); >>> + } >>> + amt.append(" if (sku == \"" + >>> variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + >>> "\"; >>> "); >>> + variantPriceJS.append(" if (sku == \"" + >>> variant.productId + "\") return \"" + >>> numberFormat.format(variantPriceMap.basePrice) + "\"; "); >>> + } >>> + amt.append(" } "); >>> + variantPriceJS.append(" } "); >>> + } >>> + jsBuf.append(amt.toString()); >>> + jsBuf.append(variantPriceJS.toString()); >>> + jsBuf.append("</script>"); >>> + >>> + context.virtualJavaScript = jsBuf.toString(); >>> + } >>> + } >>> + } >>> + } >>> +} >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:keywords = Date Rev Author URL Id >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> Added: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> URL: >>> >>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl?rev=685809&view=auto >>> >>> >>> ============================================================================== >>> --- >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> (added) >>> +++ >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> Thu Aug 14 01:37:52 2008 >>> @@ -0,0 +1,389 @@ >>> +<#-- >>> +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. >>> +--> >>> + >>> +${virtualJavaScript?if_exists} >>> +<#assign addJavaScript = requestAttributes.addJavaScript/> >>> +<#if (addJavaScript == 0)> >>> +<script language="JavaScript" type="text/javascript"> >>> + >>> + function popupDetailInline(inlineCounter) { >>> + var imageField = 'detailImage' + inlineCounter; >>> + var defaultDetailImage = document.getElementById(imageField); >>> + if (defaultDetailImage == null || defaultDetailImage == "null") >>> { >>> + defaultDetailImage = "_NONE_"; >>> + } >>> + var fieldName = 'detailImageUrl' + inlineCounter; >>> + if (window[fieldName] == null || window[fieldName] == "null") { >>> + window[fieldName] = defaultDetailImage; >>> + } >>> + >>> + if (window[fieldName] == "_NONE_") { >>> + alert("No detail image available to display."); >>> + return; >>> + } >>> + popUp("<@ofbizUrl>detailImage?detail=" + window[fieldName] + >>> "</@ofbizUrl>", 'detailImage', '400', '550'); >>> + } >>> + >>> + function setAddProductIdInline(inlineCounter, name) { >>> + var add_product_id = 'add_product_id' + inlineCounter; >>> + var product_id_display = 'product_id_display' + inlineCounter; >>> + document.configform[add_product_id].value = name; >>> + if (name == '' || name == 'NULL' || >>> isVirtualInline(inlineCounter, >>> name) == true) { >>> + //document.configform.quantity.disabled = true; >>> + var elem = document.getElementById(product_id_display); >>> + var txt = document.createTextNode(''); >>> + if(elem.hasChildNodes()) { >>> + elem.replaceChild(txt, elem.firstChild); >>> + } else { >>> + elem.appendChild(txt); >>> + } >>> + >>> + checkOtion(inlineCounter); >>> + } else { >>> + //document.configform.quantity.disabled = false; >>> + var elem = document.getElementById(product_id_display); >>> + var txt = document.createTextNode(name); >>> + if(elem.hasChildNodes()) { >>> + elem.replaceChild(txt, elem.firstChild); >>> + } else { >>> + elem.appendChild(txt); >>> + } >>> + } >>> + } >>> + >>> + function checkOtion(inlineCounter) { >>> >> >> >> I think it would be "checkOption" grammatically - but its not a big >> concern >> :) >> >> - Vikas >> >> >> + var option = document.getElementById(inlineCounter.substring(0, >>> inlineCounter.length - 2)); >>> + if (option.checked) { >>> + option.checked=false; >>> + } >>> + } >>> + >>> + function setVariantPriceInline(inlineCounter, sku) { >>> + var variant_price_display = 'variant_price_display' + >>> inlineCounter; >>> + if (sku == '' || sku == 'NULL' || isVirtualInline(inlineCounter, >>> sku) == true) { >>> + var elem = document.getElementById(variant_price_display); >>> + var txt = document.createTextNode(''); >>> + if(elem.hasChildNodes()) { >>> + elem.replaceChild(txt, elem.firstChild); >>> + } else { >>> + elem.appendChild(txt); >>> + } >>> + } >>> + else { >>> + var elem = document.getElementById(variant_price_display); >>> + var functionName = 'getVariantPrice' + inlineCounter; >>> + var price = window[functionName](sku); >>> + var txt = document.createTextNode('+' + price); >>> + if(elem.hasChildNodes()) { >>> + elem.replaceChild(txt, elem.firstChild); >>> + } else { >>> + elem.appendChild(txt); >>> + } >>> + } >>> + } >>> + function isVirtualInline(inlineCounter, product) { >>> + var isVirtual = false; >>> + var fieldName = 'VIR' + inlineCounter; >>> + <#if virtualJavaScript?exists> >>> + for (i = 0; i < window[fieldName].length; i++) { >>> + if (window[fieldName][i] == product) { >>> + isVirtual = true; >>> + } >>> + } >>> + </#if> >>> + return isVirtual; >>> + } >>> + >>> + function toggleAmtInline(inlineCounter, toggle) { >>> + var fieldName = 'add_amount' + inlineCounter; >>> + if (toggle == 'Y') { >>> + changeObjectVisibility(fieldName, "visible"); >>> + } >>> + >>> + if (toggle == 'N') { >>> + changeObjectVisibility(fieldName, "hidden"); >>> + } >>> + } >>> + >>> + function findIndexInline(varname, name ) { >>> + for (i = 0; i < window[varname].length; i++) { >>> + if ( window[varname][i] == name) { >>> + return i; >>> + } >>> + } >>> + return -1; >>> + } >>> + >>> + function checkOptionToggle(inlineCounter, disable) { >>> + var index = inlineCounter.indexOf('_'); >>> + var optionElementName = inlineCounter.substring(0,index); >>> + var option = document.getElementById(optionElementName); >>> + if ("true" == disable) { >>> + option.disabled = true; >>> + if (option.checked == true) { >>> + option.checked == false; >>> + } >>> + } else { >>> + //check all virtual product for the option >>> + } >>> + } >>> + >>> + function checkOptionVariants(optionName) { >>> + var option = document.getElementById(optionName); >>> + if (option.checked == false) { >>> + return false; >>> + } >>> + >>> + var fieldName = "add_product_id" + optionName + "_"; >>> + var index = 15 + optionName.toString().length; >>> + var cform = document.forms["configform"]; >>> + var len = cform.elements.length; >>> + for (var i = 0; i < len; i++) { >>> + var element = cform.elements[i]; >>> + if (element.name.substring(0, index) == fieldName) { >>> + if (element.value == '' || element.value == 'NULL') { >>> + option.checked = false; >>> + alert('Please select all features first'); >>> + return false; >>> + } >>> + } >>> + } >>> + } >>> + >>> + function getListInline(inlineCounter, name, index, src) { >>> + currentFeatureIndex = findIndexInline('OPT'+inlineCounter, >>> name); >>> + >>> + if (currentFeatureIndex == 0) { >>> + // set the images for the first selection >>> + if ([index] != null) { >>> + if (document.images['mainImage'+ inlineCounter] != null) >>> { >>> + document.images['mainImage'+ inlineCounter].src = >>> window['IMG'+ inlineCounter][index]; >>> + window['detailImageUrl'+ inlineCounter] = >>> window['DET'+ inlineCounter][index]; >>> + } >>> + } >>> + >>> + // set the drop down index for swatch selection >>> + document.forms["configform"].elements[name].selectedIndex = >>> (index*1)+1; >>> + } >>> + >>> + if (currentFeatureIndex < (window['OPT'+ >>> inlineCounter].length-1)) >>> { >>> + // eval the next list if there are more >>> + var selectedValue = >>> document.forms["configform"].elements[name].options[(index*1)+1].value; >>> + if (index == -1) { >>> + var featureOrderFirst = window['OPT'+ >>> inlineCounter][(currentFeatureIndex)].toString(); >>> + var length = featureOrderFirst.length; >>> + featureOrderFirst = featureOrderFirst.substring(2, >>> length); >>> + var Variable1 = eval("list" + featureOrderFirst + "()"); >>> + } else { >>> + var Variable1 = eval("list" + window['OPT'+ >>> inlineCounter][(currentFeatureIndex+1)] + selectedValue + "()"); >>> + } >>> + >>> + // set the product ID to NULL to trigger the alerts >>> + setAddProductIdInline(inlineCounter, 'NULL'); >>> + >>> + // set the variant price to NULL >>> + setVariantPriceInline(inlineCounter, 'NULL'); >>> + >>> + //checkOptionToggle(inlineCounter, 'false'); >>> + } else { >>> + // this is the final selection -- locate the selected index >>> of >>> the last selection >>> + var indexSelected = >>> document.forms["configform"].elements[name].selectedIndex; >>> + >>> + // using the selected index locate the sku >>> + var sku = >>> document.forms["configform"].elements[name].options[indexSelected].value; >>> + >>> + // set the product ID >>> + setAddProductIdInline(inlineCounter, sku); >>> + >>> + // set the variant price >>> + setVariantPriceInline(inlineCounter, sku); >>> + >>> + // check for amount box >>> + var functionName = 'checkAmtReq' + inlineCounter; >>> + toggleAmtInline(inlineCounter, window[functionName](sku)); >>> + >>> + //checkOptionToggle(inlineCounter, 'true'); >>> + } >>> + } >>> + >>> + >>> + </script> >>> +</#if> >>> + >>> +<#assign addedFeatureTreeJavaScript = >>> requestAttributes.addedFeatureTreeJavaScript?default("N")/> >>> +<#if product.virtualVariantMethodEnum?if_exists == "VV_FEATURETREE" && >>> featureLists?has_content && ("N" == addedFeatureTreeJavaScript)> >>> + ${setRequestAttribute("addedFeatureTreeJavaScript", "Y")} >>> + <script language="JavaScript" type="text/javascript"> >>> + function checkRadioButtoninline(inlineCounter, productId) { >>> + var add_product_id = 'add_product_id' + inlineCounter; >>> + <#list featureLists as featureList> >>> + <#list featureList as feature> >>> + <#if feature_index == 0> >>> + var myList = document.getElementById("FT" >>> +inlineCounter + "${feature.productFeatureTypeId}"); >>> + if (myList.options[0].selected == true) { >>> + document.configform[add_product_id].value = >>> 'NULL'; >>> + return; >>> + } >>> + <#break> >>> + </#if> >>> + </#list> >>> + </#list> >>> + document.configform[add_product_id].value = productId; >>> + } >>> + </script> >>> +</#if> >>> + >>> + >>> +<#assign price = priceMap?if_exists/> >>> +<div id="inlineproductdetail${inlineCounter}"> >>> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> >>> + <tr> >>> + <td align="left" valign="top" width="0"> >>> + <#assign productLargeImageUrl = >>> productContentWrapper.get("LARGE_IMAGE_URL")?if_exists> >>> + <#if firstLargeImage?has_content> >>> + <#assign productLargeImageUrl = firstLargeImage> >>> + </#if> >>> + <#if productLargeImageUrl?has_content> >>> + <input type="hidden" name="detailImage${inlineCounter}" >>> >>> value="${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}"/> >>> + <a href="javascript:popupDetailInline('${inlineCounter}');"><img >>> >>> src='<@ofbizContentUrl>${contentPathPrefix?if_exists}${productLargeImageUrl?if_exists}</@ofbizContentUrl>' >>> name='mainImage${inlineCounter}' vspace='5' hspace='5' border='0' >>> width='100' align='left'></a> >>> + </#if> >>> + </td> >>> + <td align="right" valign="top" width="100%"> >>> + <#-- >>> <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2> --> >>> + <#assign inStock = true> >>> + <#if product.isVirtual?if_exists?upper_case == "Y"> >>> + <#if product.virtualVariantMethodEnum?if_exists == >>> "VV_FEATURETREE" && featureLists?has_content> >>> + <#list featureLists as featureList> >>> + <#list featureList as feature> >>> + <#if feature_index == 0> >>> + <div>${feature.description}: <select >>> id="FT${inlineCounter}${feature.productFeatureTypeId}" >>> name="FT${inlineCounter}${feature.productFeatureTypeId}" >>> onChange="javascript:checkRadioButtoninline('${inlineCounter}', >>> '${product.productId}');"> >>> + <option value="select" selected="selected"> >>> select >>> option </option> >>> + <#else> >>> + <option >>> value="${feature.productFeatureId}">${feature.description} <#if >>> feature.price?exists>(+ <@ofbizCurrency amount=feature.price?string >>> isoCode=feature.currencyUomId/>)</#if></option> >>> + </#if> >>> + </#list> >>> + </select> >>> + </div> >>> + </#list> >>> + <input type="hidden" name="product_id${inlineCounter}" >>> value="${product.productId}"/> >>> + <input type="hidden" name="add_product_id${inlineCounter}" >>> value="NULL"/> >>> + </#if> >>> + <#if !product.virtualVariantMethodEnum?exists || >>> product.virtualVariantMethodEnum == "VV_VARIANTTREE"> >>> + <#if variantTree?exists && (variantTree.size() > 0)> >>> + <#list featureSet as currentType> >>> + <div> >>> + <select name="FT${inlineCounter}${currentType}" >>> onchange="javascript:getListInline('${inlineCounter}', this.name, >>> (this.selectedIndex-1), 1);"> >>> + <option>${featureTypes.get(currentType)}</option> >>> + </select> >>> + </div> >>> + </#list> >>> + <input type="hidden" name="product_id${inlineCounter}" >>> value="${product.productId}"/> >>> + <input type="hidden" name="add_product_id${inlineCounter}" >>> value="NULL"/> >>> + <div> >>> + <b><span id="product_id_display${inlineCounter}"> >>> </span></b> >>> + <b><div id="variant_price_display${inlineCounter}"> >>> </div></b> >>> + </div> >>> + <#else> >>> + <input type="hidden" name="product_id${inlineCounter}" >>> value="${product.productId}"/> >>> + <input type="hidden" name="add_product_id${inlineCounter}" >>> value="NULL"/> >>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>> + <#assign inStock = false> >>> + </#if> >>> + </#if> >>> + <#else> >>> + <input type="hidden" name="product_id${inlineCounter}" >>> value="${product.productId}"/> >>> + <input type="hidden" name="add_product_id${inlineCounter}" >>> value="${product.productId}"/> >>> + <#assign isStoreInventoryNotAvailable = >>> >>> !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, >>> product, 1.0?double))> >>> + <#assign isStoreInventoryRequired = >>> >>> Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, >>> product)> >>> + <#if isStoreInventoryNotAvailable> >>> + <#if isStoreInventoryRequired> >>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>> + <#assign inStock = false> >>> + <#else> >>> + <div><b>${product.inventoryMessage?if_exists}</b></div> >>> + </#if> >>> + </#if> >>> + </#if> >>> + </td></tr> >>> + <tr><td COLSPAN="2" align="right"> >>> + <#-- check to see if introductionDate hasnt passed yet --> >>> + <#if product.introductionDate?exists && >>> nowTimestamp.before(product.introductionDate)> >>> + <p> </p> >>> + <div style="color: >>> red;">${uiLabelMap.ProductProductNotYetMadeAvailable}.</div> >>> + <#-- check to see if salesDiscontinuationDate has passed --> >>> + <#elseif product.salesDiscontinuationDate?exists && >>> nowTimestamp.after(product.salesDiscontinuationDate)> >>> + <div style="color: >>> red;">${uiLabelMap.ProductProductNoLongerAvailable}.</div> >>> + <#-- check to see if the product requires inventory check and >>> has >>> inventory --> >>> + <#elseif product.virtualVariantMethodEnum?if_exists != >>> "VV_FEATURETREE"> >>> + <#if inStock> >>> + <#if product.requireAmount?default("N") == "Y"> >>> + <#assign hiddenStyle = "visible"> >>> + <#else> >>> + <#assign hiddenStyle = "hidden"> >>> + </#if> >>> + <div id="add_amount${inlineCounter}" class="${hiddenStyle}"> >>> + <span style="white-space: >>> nowrap;"><b>${uiLabelMap.CommonAmount}:</b></span> >>> + <input type="text" size="5" >>> name="add_amount${inlineCounter}" value=""/> >>> + </div> >>> + </#if> >>> + </#if> >>> + </td></tr> >>> + >>> + <tr><td COLSPAN="2" align="right"> >>> + <#if variantTree?exists && 0 < variantTree.size()> >>> + <script language="JavaScript" >>> type="text/javascript">eval("list"+ >>> "${inlineCounter}" + "${featureOrderFirst}" + "()");</script> >>> + </#if> >>> + >>> + <#-- Swatches (virtual products only) . For now commented out, >>> before fixing a bug >>> + <#if variantSample?exists && 0 < variantSample.size()> >>> + <#assign imageKeys = variantSample.keySet()> >>> + <#assign imageMap = variantSample> >>> + <p> </p> >>> + <table cellspacing="0" cellpadding="0"> >>> + <tr> >>> + <#assign maxIndex = 7> >>> + <#assign indexer = 0> >>> + <#list imageKeys as key> >>> + <#assign swatchProduct = imageMap.get(key)> >>> + <#if swatchProduct?has_content && indexer < maxIndex> >>> + <#assign imageUrl = >>> >>> Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(swatchProduct, >>> "SMALL_IMAGE_URL", request)?if_exists> >>> + <#if !imageUrl?has_content> >>> + <#assign imageUrl = >>> productContentWrapper.get("SMALL_IMAGE_URL")?if_exists> >>> + </#if> >>> + <#if !imageUrl?has_content> >>> + <#assign imageUrl = "/images/defaultImage.jpg"> >>> + </#if> >>> + <td align="center" valign="bottom"> >>> + <a href="javascript:getListInline('${inlineCounter}', >>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);"><img >>> >>> src="<@ofbizContentUrl>${contentPathPrefix?if_exists}${imageUrl}</@ofbizContentUrl>" >>> border="0" width="60" height="60"></a> >>> + <br/> >>> + <a href="javascript:getListInline('${inlineCounter}', >>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);" >>> class="linktext">${key}</a> >>> + </td> >>> + </#if> >>> + <#assign indexer = indexer + 1> >>> + </#list> >>> + <#if (indexer > maxIndex)> >>> + <div><b>${uiLabelMap.ProductMoreOptions}</b></div> >>> + </#if> >>> + </tr> >>> + </table> >>> + </#if> --> >>> + </td> >>> + </tr> >>> +</table> >>> +</div> >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:eol-style = native >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:keywords = Date Rev Author URL Id >>> >>> Propchange: >>> >>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>> >>> >>> ------------------------------------------------------------------------------ >>> svn:mime-type = text/plain >>> >>> >>> >>> >> > |
Administrator
|
Mmm... I see... kind of Ravana http://fr.wikipedia.org/wiki/Image:Ravana.jpg ?
I will take care ;o) Jacques PS : sorry Vikas, I don't know much about Hinduism, and this one seems to be a demon :/. Anyway it's Ashish's fault :p From: "Ashish Vijaywargiya" <[hidden email]> > Jacques, Do you know Vikas has 10 Eyes :D ? > > -- > Ashish Vijaywargiya > Indore (M.P), India > http://en.wikipedia.org/wiki/Indore > > > > > On Thu, Aug 21, 2008 at 4:05 PM, Jacques Le Roux < > [hidden email]> wrote: > >> Wooow, hard to find :D >> >> Jacques >> >> From: "Vikas Mayur" <[hidden email]> >> >> On Thu, Aug 14, 2008 at 2:07 PM, <[hidden email]> wrote: >>> >>> Author: bibryam >>>> Date: Thu Aug 14 01:37:52 2008 >>>> New Revision: 685809 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=685809&view=rev >>>> Log: >>>> Missed these files in my previous commit. >>>> >>>> Added: >>>> >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> (with props) >>>> >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> (with props) >>>> >>>> Added: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy?rev=685809&view=auto >>>> >>>> >>>> ============================================================================== >>>> --- >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> (added) >>>> +++ >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> Thu Aug 14 01:37:52 2008 >>>> @@ -0,0 +1,311 @@ >>>> +/* >>>> + * 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.lang.*; >>>> +import java.util.*; >>>> +import java.text.NumberFormat; >>>> +import org.ofbiz.base.util.*; >>>> +import org.ofbiz.service.*; >>>> +import org.ofbiz.entity.*; >>>> +import org.ofbiz.entity.condition.*; >>>> +import org.ofbiz.entity.util.*; >>>> +import org.ofbiz.webapp.taglib.*; >>>> +import org.ofbiz.webapp.stats.VisitHandler; >>>> +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; >>>> +import org.ofbiz.product.catalog.*; >>>> +import org.ofbiz.product.category.*; >>>> +import org.ofbiz.product.product.ProductWorker; >>>> +import org.ofbiz.product.product.ProductContentWrapper; >>>> +import org.ofbiz.product.product.ProductSearch; >>>> +import org.ofbiz.product.product.ProductSearchSession; >>>> +import org.ofbiz.product.store.*; >>>> + >>>> +inlineProductId = request.getAttribute("inlineProductId"); >>>> +inlineCounter = request.getAttribute("inlineCounter"); >>>> +context.inlineCounter = inlineCounter; >>>> +context.inlineProductId = inlineProductId; >>>> + >>>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>>> +catalogName = CatalogWorker.getCatalogName(request); >>>> +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); >>>> + >>>> +if (inlineProductId) { >>>> + inlineProduct = delegator.findByPrimaryKeyCache("Product", >>>> [productId >>>> : inlineProductId]); >>>> + if (inlineProduct) { >>>> + context.product = inlineProduct; >>>> + contentWrapper = new ProductContentWrapper(inlineProduct, >>>> request); >>>> + context.put("title", contentWrapper.get("PRODUCT_NAME")); >>>> + context.put("metaDescription", >>>> contentWrapper.get("DESCRIPTION")); >>>> + productTemplate = product.detailScreen; >>>> + if (productTemplate) { >>>> + detailScreen = productTemplate; >>>> + } >>>> + } >>>> +} >>>> + >>>> +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); >>>> +if (templatePathPrefix) { >>>> + detailScreen = templatePathPrefix + detailScreen; >>>> +} >>>> +context.detailScreen = detailScreen; >>>> + >>>> +String buildNext(Map map, List order, String current, String prefix, Map >>>> featureTypes) { >>>> + def ct = 0; >>>> + def buf = new StringBuffer(); >>>> + buf.append("function listFT" + inlineCounter + current + prefix + >>>> "() >>>> { "); >>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter + current + "\"].options.length = 1;"); >>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter + current + "\"].options[0] = new Option(\"" + >>>> featureTypes[current] + "\",\"\",true,true);"); >>>> + map.each { key, value -> >>>> + def optValue = null; >>>> + >>>> + if (order.indexOf(current) == (order.size()-1)) { >>>> + optValue = value.iterator().next(); >>>> + } else { >>>> + optValue = prefix + "_" + ct; >>>> + } >>>> + >>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter + current + "\"].options[" + (ct + 1) + "] = new Option(\"" >>>> + >>>> key + "\",\"" + optValue + "\");"); >>>> + ct++; >>>> + } >>>> + buf.append(" }"); >>>> + if (order.indexOf(current) < (order.size()-1)) { >>>> + ct = 0; >>>> + map.each { key, value -> >>>> + def nextOrder = order.get(order.indexOf(current)+1); >>>> + def newPrefix = prefix + "_" + ct; >>>> + buf.append(buildNext(value, order, nextOrder, newPrefix, >>>> featureTypes)); >>>> + ct++; >>>> + } >>>> + } >>>> + return buf.toString(); >>>> +} >>>> + >>>> +cart = ShoppingCartEvents.getCartObject(request); >>>> + >>>> +// set the content path prefix >>>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>>> +context.contentPathPrefix = contentPathPrefix; >>>> + >>>> +// get the product detail information >>>> +if (inlineProduct) { >>>> + inlineProductId = inlineProduct.productId; >>>> + productTypeId = inlineProduct.productTypeId; >>>> + featureTypes = [:]; >>>> + featureOrder = []; >>>> + >>>> + // make the productContentWrapper >>>> + productContentWrapper = new ProductContentWrapper(inlineProduct, >>>> request); >>>> + context.productContentWrapper = productContentWrapper; >>>> + >>>> + // get the main detail image (virtual or single product) >>>> + mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL"); >>>> + if (mainDetailImage) { >>>> + mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + >>>> mainDetailImage; >>>> + mainDetailImageUrl = >>>> URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8"); >>>> + context.mainDetailImageUrl = mainDetailImageUrl; >>>> + } >>>> + >>>> + >>>> + // get the product price >>>> + webSiteId = CatalogWorker.getWebSiteId(request); >>>> + autoUserLogin = request.getSession().getAttribute("autoUserLogin"); >>>> + if (cart.isSalesOrder()) { >>>> + // sales order: run the "calculateProductPrice" service >>>> + priceContext = [product : inlineProduct, prodCatalogId : >>>> currentCatalogId, >>>> + currencyUomId : cart.getCurrency(), autoUserLogin : >>>> autoUserLogin]; >>>> + priceContext.webSiteId = webSiteId; >>>> + priceContext.productStoreId = productStoreId; >>>> + priceContext.checkIncludeVat = "Y"; >>>> + priceContext.agreementId = cart.getAgreementId(); >>>> + priceContext.partyId = cart.getPartyId(); // IMPORTANT: must >>>> put >>>> this in, or price will be calculated for the CSR instead of the customer >>>> + priceMap = dispatcher.runSync("calculateProductPrice", >>>> priceContext); >>>> + context.priceMap = priceMap; >>>> + } else { >>>> + // purchase order: run the "calculatePurchasePrice" service >>>> + priceContext = [product : inlineProduct, currencyUomId : >>>> cart.getCurrency(), >>>> + partyId : cart.getPartyId(), userLogin : userLogin]; >>>> + priceMap = dispatcher.runSync("calculatePurchasePrice", >>>> priceContext); >>>> + context.priceMap = priceMap; >>>> + } >>>> + >>>> + >>>> + context.variantTree = null; >>>> + context.variantTreeSize = null; >>>> + context.variantSample = null; >>>> + context.variantSampleKeys = null; >>>> + context.variantSampleSize = null; >>>> + if ("Y".equals(inlineProduct.isVirtual)) { >>>> + if >>>> >>>> ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod(delegator, >>>> inlineProductId))) { >>>> + context.featureLists = >>>> ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct); >>>> + } else { >>>> + featureMap = dispatcher.runSync("getProductFeatureSet", >>>> [productId : inlineProductId]); >>>> + featureSet = featureMap.featureSet; >>>> + if (featureSet) { >>>> + variantTreeMap = >>>> dispatcher.runSync("getProductVariantTree", [productId : inlineProductId, >>>> featureOrder : featureSet, productStoreId : productStoreId]); >>>> + variantTree = variantTreeMap.variantTree; >>>> + imageMap = variantTreeMap.variantSample; >>>> + virtualVariant = variantTreeMap.virtualVariant; >>>> + context.virtualVariant = virtualVariant; >>>> + if (variantTree) { >>>> + context.variantTree = variantTree; >>>> + context.variantTreeSize = variantTree.size(); >>>> + } >>>> + if (imageMap) { >>>> + context.variantSample = imageMap; >>>> + context.variantSampleKeys = imageMap.keySet(); >>>> + context.variantSampleSize = imageMap.size(); >>>> + } >>>> + context.featureSet = featureSet; >>>> + >>>> + if (variantTree) { >>>> + featureOrder = new LinkedList(featureSet); >>>> + featureOrder.each { featureKey -> >>>> + featureValue = >>>> delegator.findByPrimaryKeyCache("ProductFeatureType", >>>> [productFeatureTypeId >>>> : featureKey]); >>>> + fValue = featureValue.get("description") ?: >>>> featureValue.productFeatureTypeId; >>>> + featureTypes[featureKey] = fValue; >>>> + } >>>> + } >>>> + context.featureTypes = featureTypes; >>>> + context.featureOrder = featureOrder; >>>> + if (featureOrder) { >>>> + context.featureOrderFirst = featureOrder[0]; >>>> + } >>>> + >>>> + if (variantTree && imageMap) { >>>> + jsBuf = new StringBuffer(); >>>> + jsBuf.append("<script language=\"JavaScript\">"); >>>> + jsBuf.append("var DET" + inlineCounter + "= new >>>> Array(" + variantTree.size() + ");"); >>>> + jsBuf.append("var IMG" + inlineCounter + " = new >>>> Array(" + variantTree.size() + ");"); >>>> + jsBuf.append("var OPT" + inlineCounter + " = new >>>> Array(" + featureOrder.size() + ");"); >>>> + jsBuf.append("var VIR" + inlineCounter + " = new >>>> Array(" + virtualVariant.size() + ");"); >>>> + jsBuf.append("var detailImageUrl" + inlineCounter + >>>> " >>>> = null;"); >>>> + featureOrder.eachWithIndex { feature, i -> >>>> + jsBuf.append("OPT" + inlineCounter + "[" + i + >>>> "] >>>> = \"FT" + inlineCounter + feature + "\";"); >>>> + } >>>> + virtualVariant.eachWithIndex { variant, i -> >>>> + jsBuf.append("VIR" + inlineCounter + "[" + i + >>>> "] >>>> = \"" + variant + "\";"); >>>> + } >>>> + >>>> + // build the top level >>>> + topLevelName = featureOrder[0]; >>>> + jsBuf.append("function list" + inlineCounter + >>>> topLevelName + "() {"); >>>> + >>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter >>>> + topLevelName + "\"].options.length = 1;"); >>>> + >>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter >>>> + topLevelName + "\"].options[0] = new Option(\"" + >>>> featureTypes[topLevelName] + "\",\"\",true,true);"); >>>> + if (variantTree) { >>>> + featureOrder.each { featureKey -> >>>> + >>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter >>>> + featureKey + "\"].options.length = 1;"); >>>> + } >>>> + firstDetailImage = null; >>>> + firstLargeImage = null; >>>> + counter = 0; >>>> + variantTree.each { key, value -> >>>> + opt = null; >>>> + if (featureOrder.size() == 1) { >>>> + opt = value.iterator().next(); >>>> + } else { >>>> + opt = counter as String; >>>> + } >>>> + // create the variant content wrapper >>>> + contentWrapper = new >>>> ProductContentWrapper(imageMap[key], request); >>>> + >>>> + // initial image paths >>>> + detailImage = >>>> contentWrapper.get("DETAIL_IMAGE_URL") ?: >>>> productContentWrapper.get("DETAIL_IMAGE_URL"); >>>> + largeImage = >>>> contentWrapper.get("LARGE_IMAGE_URL") ?: >>>> productContentWrapper.get("LARGE_IMAGE_URL"); >>>> + >>>> + // full image URLs >>>> + detailImageUrl = null; >>>> + largeImageUrl = null; >>>> + >>>> + // append the content prefix >>>> + if (detailImage) { >>>> + detailImageUrl = >>>> ContentUrlTag.getContentPrefix(request) + detailImage; >>>> + // base64 encode the image url for a >>>> little protection >>>> + detailImageUrl = >>>> URLEncoder.encode(Base64.base64Encode(detailImageUrl), "UTF-8"); >>>> + } >>>> + if (largeImage) { >>>> + largeImageUrl = >>>> ContentUrlTag.getContentPrefix(request) + largeImage; >>>> + } >>>> + >>>> + >>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>> inlineCounter >>>> + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + key >>>> + >>>> "\",\"" + opt + "\");"); >>>> + jsBuf.append("DET" + inlineCounter + "[" + >>>> counter + "] = \"" + detailImageUrl +"\";"); >>>> + jsBuf.append("IMG" + inlineCounter + "[" + >>>> counter + "] = \"" + largeImageUrl +"\";"); >>>> + >>>> + if (!firstDetailImage) { >>>> + firstDetailImage = detailImageUrl; >>>> + } >>>> + if (!firstLargeImage) { >>>> + firstLargeImage = largeImage; >>>> + } >>>> + counter++; >>>> + } >>>> + context.firstDetailImage = firstDetailImage; >>>> + context.firstLargeImage = firstLargeImage; >>>> + } >>>> + jsBuf.append("}"); >>>> + >>>> + // build dynamic lists >>>> + if (variantTree) { >>>> + variantTree.values().eachWithIndex { varTree, >>>> topLevelKeysCt -> >>>> + cnt = "" + topLevelKeysCt; >>>> + if (varTree instanceof Map) { >>>> + jsBuf.append(buildNext(varTree, >>>> featureOrder, featureOrder[1], cnt, featureTypes)); >>>> + } >>>> + } >>>> + } >>>> + >>>> + // make a list of variant sku with requireAmount >>>> + variantsRes = >>>> dispatcher.runSync("getAssociatedProducts", [productId : inlineProductId, >>>> type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : >>>> currentCatalogId]); >>>> + variants = variantsRes.assocProducts; >>>> + if (variants) { >>>> + amt = new StringBuffer(); >>>> + amt.append("function checkAmtReq" + >>>> inlineCounter >>>> + "(sku) { "); >>>> + // Create the javascript to return the price for >>>> each variant >>>> + variantPriceJS = new StringBuffer(); >>>> + variantPriceJS.append("function getVariantPrice" >>>> + >>>> inlineCounter + "(sku) { "); >>>> + // Format to apply the currency code to the >>>> variant price in the javascript >>>> + productStore = >>>> ProductStoreWorker.getProductStore(request); >>>> + localeString = productStore.defaultLocaleString; >>>> + if (localeString) { >>>> + locale = UtilMisc.parseLocale(localeString); >>>> + } >>>> + numberFormat = >>>> NumberFormat.getCurrencyInstance(locale); >>>> + variants.each { variantAssoc -> >>>> + variant = >>>> variantAssoc.getRelatedOne("AssocProduct"); >>>> + // Get the price for each variant. Reuse the >>>> priceContext already setup for virtual product above and replace the >>>> product >>>> + if (cart.isSalesOrder()) { >>>> + // sales order: run the >>>> "calculateProductPrice" service >>>> + priceContext.product = variant; >>>> + variantPriceMap = >>>> dispatcher.runSync("calculateProductPrice", priceContext); >>>> + } >>>> + amt.append(" if (sku == \"" + >>>> variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + >>>> "\"; >>>> "); >>>> + variantPriceJS.append(" if (sku == \"" + >>>> variant.productId + "\") return \"" + >>>> numberFormat.format(variantPriceMap.basePrice) + "\"; "); >>>> + } >>>> + amt.append(" } "); >>>> + variantPriceJS.append(" } "); >>>> + } >>>> + jsBuf.append(amt.toString()); >>>> + jsBuf.append(variantPriceJS.toString()); >>>> + jsBuf.append("</script>"); >>>> + >>>> + context.virtualJavaScript = jsBuf.toString(); >>>> + } >>>> + } >>>> + } >>>> + } >>>> +} >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:keywords = Date Rev Author URL Id >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:mime-type = text/plain >>>> >>>> Added: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl?rev=685809&view=auto >>>> >>>> >>>> ============================================================================== >>>> --- >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> (added) >>>> +++ >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> Thu Aug 14 01:37:52 2008 >>>> @@ -0,0 +1,389 @@ >>>> +<#-- >>>> +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. >>>> +--> >>>> + >>>> +${virtualJavaScript?if_exists} >>>> +<#assign addJavaScript = requestAttributes.addJavaScript/> >>>> +<#if (addJavaScript == 0)> >>>> +<script language="JavaScript" type="text/javascript"> >>>> + >>>> + function popupDetailInline(inlineCounter) { >>>> + var imageField = 'detailImage' + inlineCounter; >>>> + var defaultDetailImage = document.getElementById(imageField); >>>> + if (defaultDetailImage == null || defaultDetailImage == "null") >>>> { >>>> + defaultDetailImage = "_NONE_"; >>>> + } >>>> + var fieldName = 'detailImageUrl' + inlineCounter; >>>> + if (window[fieldName] == null || window[fieldName] == "null") { >>>> + window[fieldName] = defaultDetailImage; >>>> + } >>>> + >>>> + if (window[fieldName] == "_NONE_") { >>>> + alert("No detail image available to display."); >>>> + return; >>>> + } >>>> + popUp("<@ofbizUrl>detailImage?detail=" + window[fieldName] + >>>> "</@ofbizUrl>", 'detailImage', '400', '550'); >>>> + } >>>> + >>>> + function setAddProductIdInline(inlineCounter, name) { >>>> + var add_product_id = 'add_product_id' + inlineCounter; >>>> + var product_id_display = 'product_id_display' + inlineCounter; >>>> + document.configform[add_product_id].value = name; >>>> + if (name == '' || name == 'NULL' || >>>> isVirtualInline(inlineCounter, >>>> name) == true) { >>>> + //document.configform.quantity.disabled = true; >>>> + var elem = document.getElementById(product_id_display); >>>> + var txt = document.createTextNode(''); >>>> + if(elem.hasChildNodes()) { >>>> + elem.replaceChild(txt, elem.firstChild); >>>> + } else { >>>> + elem.appendChild(txt); >>>> + } >>>> + >>>> + checkOtion(inlineCounter); >>>> + } else { >>>> + //document.configform.quantity.disabled = false; >>>> + var elem = document.getElementById(product_id_display); >>>> + var txt = document.createTextNode(name); >>>> + if(elem.hasChildNodes()) { >>>> + elem.replaceChild(txt, elem.firstChild); >>>> + } else { >>>> + elem.appendChild(txt); >>>> + } >>>> + } >>>> + } >>>> + >>>> + function checkOtion(inlineCounter) { >>>> >>> >>> >>> I think it would be "checkOption" grammatically - but its not a big >>> concern >>> :) >>> >>> - Vikas >>> >>> >>> + var option = document.getElementById(inlineCounter.substring(0, >>>> inlineCounter.length - 2)); >>>> + if (option.checked) { >>>> + option.checked=false; >>>> + } >>>> + } >>>> + >>>> + function setVariantPriceInline(inlineCounter, sku) { >>>> + var variant_price_display = 'variant_price_display' + >>>> inlineCounter; >>>> + if (sku == '' || sku == 'NULL' || isVirtualInline(inlineCounter, >>>> sku) == true) { >>>> + var elem = document.getElementById(variant_price_display); >>>> + var txt = document.createTextNode(''); >>>> + if(elem.hasChildNodes()) { >>>> + elem.replaceChild(txt, elem.firstChild); >>>> + } else { >>>> + elem.appendChild(txt); >>>> + } >>>> + } >>>> + else { >>>> + var elem = document.getElementById(variant_price_display); >>>> + var functionName = 'getVariantPrice' + inlineCounter; >>>> + var price = window[functionName](sku); >>>> + var txt = document.createTextNode('+' + price); >>>> + if(elem.hasChildNodes()) { >>>> + elem.replaceChild(txt, elem.firstChild); >>>> + } else { >>>> + elem.appendChild(txt); >>>> + } >>>> + } >>>> + } >>>> + function isVirtualInline(inlineCounter, product) { >>>> + var isVirtual = false; >>>> + var fieldName = 'VIR' + inlineCounter; >>>> + <#if virtualJavaScript?exists> >>>> + for (i = 0; i < window[fieldName].length; i++) { >>>> + if (window[fieldName][i] == product) { >>>> + isVirtual = true; >>>> + } >>>> + } >>>> + </#if> >>>> + return isVirtual; >>>> + } >>>> + >>>> + function toggleAmtInline(inlineCounter, toggle) { >>>> + var fieldName = 'add_amount' + inlineCounter; >>>> + if (toggle == 'Y') { >>>> + changeObjectVisibility(fieldName, "visible"); >>>> + } >>>> + >>>> + if (toggle == 'N') { >>>> + changeObjectVisibility(fieldName, "hidden"); >>>> + } >>>> + } >>>> + >>>> + function findIndexInline(varname, name ) { >>>> + for (i = 0; i < window[varname].length; i++) { >>>> + if ( window[varname][i] == name) { >>>> + return i; >>>> + } >>>> + } >>>> + return -1; >>>> + } >>>> + >>>> + function checkOptionToggle(inlineCounter, disable) { >>>> + var index = inlineCounter.indexOf('_'); >>>> + var optionElementName = inlineCounter.substring(0,index); >>>> + var option = document.getElementById(optionElementName); >>>> + if ("true" == disable) { >>>> + option.disabled = true; >>>> + if (option.checked == true) { >>>> + option.checked == false; >>>> + } >>>> + } else { >>>> + //check all virtual product for the option >>>> + } >>>> + } >>>> + >>>> + function checkOptionVariants(optionName) { >>>> + var option = document.getElementById(optionName); >>>> + if (option.checked == false) { >>>> + return false; >>>> + } >>>> + >>>> + var fieldName = "add_product_id" + optionName + "_"; >>>> + var index = 15 + optionName.toString().length; >>>> + var cform = document.forms["configform"]; >>>> + var len = cform.elements.length; >>>> + for (var i = 0; i < len; i++) { >>>> + var element = cform.elements[i]; >>>> + if (element.name.substring(0, index) == fieldName) { >>>> + if (element.value == '' || element.value == 'NULL') { >>>> + option.checked = false; >>>> + alert('Please select all features first'); >>>> + return false; >>>> + } >>>> + } >>>> + } >>>> + } >>>> + >>>> + function getListInline(inlineCounter, name, index, src) { >>>> + currentFeatureIndex = findIndexInline('OPT'+inlineCounter, >>>> name); >>>> + >>>> + if (currentFeatureIndex == 0) { >>>> + // set the images for the first selection >>>> + if ([index] != null) { >>>> + if (document.images['mainImage'+ inlineCounter] != null) >>>> { >>>> + document.images['mainImage'+ inlineCounter].src = >>>> window['IMG'+ inlineCounter][index]; >>>> + window['detailImageUrl'+ inlineCounter] = >>>> window['DET'+ inlineCounter][index]; >>>> + } >>>> + } >>>> + >>>> + // set the drop down index for swatch selection >>>> + document.forms["configform"].elements[name].selectedIndex = >>>> (index*1)+1; >>>> + } >>>> + >>>> + if (currentFeatureIndex < (window['OPT'+ >>>> inlineCounter].length-1)) >>>> { >>>> + // eval the next list if there are more >>>> + var selectedValue = >>>> document.forms["configform"].elements[name].options[(index*1)+1].value; >>>> + if (index == -1) { >>>> + var featureOrderFirst = window['OPT'+ >>>> inlineCounter][(currentFeatureIndex)].toString(); >>>> + var length = featureOrderFirst.length; >>>> + featureOrderFirst = featureOrderFirst.substring(2, >>>> length); >>>> + var Variable1 = eval("list" + featureOrderFirst + "()"); >>>> + } else { >>>> + var Variable1 = eval("list" + window['OPT'+ >>>> inlineCounter][(currentFeatureIndex+1)] + selectedValue + "()"); >>>> + } >>>> + >>>> + // set the product ID to NULL to trigger the alerts >>>> + setAddProductIdInline(inlineCounter, 'NULL'); >>>> + >>>> + // set the variant price to NULL >>>> + setVariantPriceInline(inlineCounter, 'NULL'); >>>> + >>>> + //checkOptionToggle(inlineCounter, 'false'); >>>> + } else { >>>> + // this is the final selection -- locate the selected index >>>> of >>>> the last selection >>>> + var indexSelected = >>>> document.forms["configform"].elements[name].selectedIndex; >>>> + >>>> + // using the selected index locate the sku >>>> + var sku = >>>> document.forms["configform"].elements[name].options[indexSelected].value; >>>> + >>>> + // set the product ID >>>> + setAddProductIdInline(inlineCounter, sku); >>>> + >>>> + // set the variant price >>>> + setVariantPriceInline(inlineCounter, sku); >>>> + >>>> + // check for amount box >>>> + var functionName = 'checkAmtReq' + inlineCounter; >>>> + toggleAmtInline(inlineCounter, window[functionName](sku)); >>>> + >>>> + //checkOptionToggle(inlineCounter, 'true'); >>>> + } >>>> + } >>>> + >>>> + >>>> + </script> >>>> +</#if> >>>> + >>>> +<#assign addedFeatureTreeJavaScript = >>>> requestAttributes.addedFeatureTreeJavaScript?default("N")/> >>>> +<#if product.virtualVariantMethodEnum?if_exists == "VV_FEATURETREE" && >>>> featureLists?has_content && ("N" == addedFeatureTreeJavaScript)> >>>> + ${setRequestAttribute("addedFeatureTreeJavaScript", "Y")} >>>> + <script language="JavaScript" type="text/javascript"> >>>> + function checkRadioButtoninline(inlineCounter, productId) { >>>> + var add_product_id = 'add_product_id' + inlineCounter; >>>> + <#list featureLists as featureList> >>>> + <#list featureList as feature> >>>> + <#if feature_index == 0> >>>> + var myList = document.getElementById("FT" >>>> +inlineCounter + "${feature.productFeatureTypeId}"); >>>> + if (myList.options[0].selected == true) { >>>> + document.configform[add_product_id].value = >>>> 'NULL'; >>>> + return; >>>> + } >>>> + <#break> >>>> + </#if> >>>> + </#list> >>>> + </#list> >>>> + document.configform[add_product_id].value = productId; >>>> + } >>>> + </script> >>>> +</#if> >>>> + >>>> + >>>> +<#assign price = priceMap?if_exists/> >>>> +<div id="inlineproductdetail${inlineCounter}"> >>>> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> >>>> + <tr> >>>> + <td align="left" valign="top" width="0"> >>>> + <#assign productLargeImageUrl = >>>> productContentWrapper.get("LARGE_IMAGE_URL")?if_exists> >>>> + <#if firstLargeImage?has_content> >>>> + <#assign productLargeImageUrl = firstLargeImage> >>>> + </#if> >>>> + <#if productLargeImageUrl?has_content> >>>> + <input type="hidden" name="detailImage${inlineCounter}" >>>> >>>> value="${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}"/> >>>> + <a href="javascript:popupDetailInline('${inlineCounter}');"><img >>>> >>>> src='<@ofbizContentUrl>${contentPathPrefix?if_exists}${productLargeImageUrl?if_exists}</@ofbizContentUrl>' >>>> name='mainImage${inlineCounter}' vspace='5' hspace='5' border='0' >>>> width='100' align='left'></a> >>>> + </#if> >>>> + </td> >>>> + <td align="right" valign="top" width="100%"> >>>> + <#-- >>>> <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2> --> >>>> + <#assign inStock = true> >>>> + <#if product.isVirtual?if_exists?upper_case == "Y"> >>>> + <#if product.virtualVariantMethodEnum?if_exists == >>>> "VV_FEATURETREE" && featureLists?has_content> >>>> + <#list featureLists as featureList> >>>> + <#list featureList as feature> >>>> + <#if feature_index == 0> >>>> + <div>${feature.description}: <select >>>> id="FT${inlineCounter}${feature.productFeatureTypeId}" >>>> name="FT${inlineCounter}${feature.productFeatureTypeId}" >>>> onChange="javascript:checkRadioButtoninline('${inlineCounter}', >>>> '${product.productId}');"> >>>> + <option value="select" selected="selected"> >>>> select >>>> option </option> >>>> + <#else> >>>> + <option >>>> value="${feature.productFeatureId}">${feature.description} <#if >>>> feature.price?exists>(+ <@ofbizCurrency amount=feature.price?string >>>> isoCode=feature.currencyUomId/>)</#if></option> >>>> + </#if> >>>> + </#list> >>>> + </select> >>>> + </div> >>>> + </#list> >>>> + <input type="hidden" name="product_id${inlineCounter}" >>>> value="${product.productId}"/> >>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>> value="NULL"/> >>>> + </#if> >>>> + <#if !product.virtualVariantMethodEnum?exists || >>>> product.virtualVariantMethodEnum == "VV_VARIANTTREE"> >>>> + <#if variantTree?exists && (variantTree.size() > 0)> >>>> + <#list featureSet as currentType> >>>> + <div> >>>> + <select name="FT${inlineCounter}${currentType}" >>>> onchange="javascript:getListInline('${inlineCounter}', this.name, >>>> (this.selectedIndex-1), 1);"> >>>> + <option>${featureTypes.get(currentType)}</option> >>>> + </select> >>>> + </div> >>>> + </#list> >>>> + <input type="hidden" name="product_id${inlineCounter}" >>>> value="${product.productId}"/> >>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>> value="NULL"/> >>>> + <div> >>>> + <b><span id="product_id_display${inlineCounter}"> >>>> </span></b> >>>> + <b><div id="variant_price_display${inlineCounter}"> >>>> </div></b> >>>> + </div> >>>> + <#else> >>>> + <input type="hidden" name="product_id${inlineCounter}" >>>> value="${product.productId}"/> >>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>> value="NULL"/> >>>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>>> + <#assign inStock = false> >>>> + </#if> >>>> + </#if> >>>> + <#else> >>>> + <input type="hidden" name="product_id${inlineCounter}" >>>> value="${product.productId}"/> >>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>> value="${product.productId}"/> >>>> + <#assign isStoreInventoryNotAvailable = >>>> >>>> !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, >>>> product, 1.0?double))> >>>> + <#assign isStoreInventoryRequired = >>>> >>>> Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, >>>> product)> >>>> + <#if isStoreInventoryNotAvailable> >>>> + <#if isStoreInventoryRequired> >>>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>>> + <#assign inStock = false> >>>> + <#else> >>>> + <div><b>${product.inventoryMessage?if_exists}</b></div> >>>> + </#if> >>>> + </#if> >>>> + </#if> >>>> + </td></tr> >>>> + <tr><td COLSPAN="2" align="right"> >>>> + <#-- check to see if introductionDate hasnt passed yet --> >>>> + <#if product.introductionDate?exists && >>>> nowTimestamp.before(product.introductionDate)> >>>> + <p> </p> >>>> + <div style="color: >>>> red;">${uiLabelMap.ProductProductNotYetMadeAvailable}.</div> >>>> + <#-- check to see if salesDiscontinuationDate has passed --> >>>> + <#elseif product.salesDiscontinuationDate?exists && >>>> nowTimestamp.after(product.salesDiscontinuationDate)> >>>> + <div style="color: >>>> red;">${uiLabelMap.ProductProductNoLongerAvailable}.</div> >>>> + <#-- check to see if the product requires inventory check and >>>> has >>>> inventory --> >>>> + <#elseif product.virtualVariantMethodEnum?if_exists != >>>> "VV_FEATURETREE"> >>>> + <#if inStock> >>>> + <#if product.requireAmount?default("N") == "Y"> >>>> + <#assign hiddenStyle = "visible"> >>>> + <#else> >>>> + <#assign hiddenStyle = "hidden"> >>>> + </#if> >>>> + <div id="add_amount${inlineCounter}" class="${hiddenStyle}"> >>>> + <span style="white-space: >>>> nowrap;"><b>${uiLabelMap.CommonAmount}:</b></span> >>>> + <input type="text" size="5" >>>> name="add_amount${inlineCounter}" value=""/> >>>> + </div> >>>> + </#if> >>>> + </#if> >>>> + </td></tr> >>>> + >>>> + <tr><td COLSPAN="2" align="right"> >>>> + <#if variantTree?exists && 0 < variantTree.size()> >>>> + <script language="JavaScript" >>>> type="text/javascript">eval("list"+ >>>> "${inlineCounter}" + "${featureOrderFirst}" + "()");</script> >>>> + </#if> >>>> + >>>> + <#-- Swatches (virtual products only) . For now commented out, >>>> before fixing a bug >>>> + <#if variantSample?exists && 0 < variantSample.size()> >>>> + <#assign imageKeys = variantSample.keySet()> >>>> + <#assign imageMap = variantSample> >>>> + <p> </p> >>>> + <table cellspacing="0" cellpadding="0"> >>>> + <tr> >>>> + <#assign maxIndex = 7> >>>> + <#assign indexer = 0> >>>> + <#list imageKeys as key> >>>> + <#assign swatchProduct = imageMap.get(key)> >>>> + <#if swatchProduct?has_content && indexer < maxIndex> >>>> + <#assign imageUrl = >>>> >>>> Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(swatchProduct, >>>> "SMALL_IMAGE_URL", request)?if_exists> >>>> + <#if !imageUrl?has_content> >>>> + <#assign imageUrl = >>>> productContentWrapper.get("SMALL_IMAGE_URL")?if_exists> >>>> + </#if> >>>> + <#if !imageUrl?has_content> >>>> + <#assign imageUrl = "/images/defaultImage.jpg"> >>>> + </#if> >>>> + <td align="center" valign="bottom"> >>>> + <a href="javascript:getListInline('${inlineCounter}', >>>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);"><img >>>> >>>> src="<@ofbizContentUrl>${contentPathPrefix?if_exists}${imageUrl}</@ofbizContentUrl>" >>>> border="0" width="60" height="60"></a> >>>> + <br/> >>>> + <a href="javascript:getListInline('${inlineCounter}', >>>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);" >>>> class="linktext">${key}</a> >>>> + </td> >>>> + </#if> >>>> + <#assign indexer = indexer + 1> >>>> + </#list> >>>> + <#if (indexer > maxIndex)> >>>> + <div><b>${uiLabelMap.ProductMoreOptions}</b></div> >>>> + </#if> >>>> + </tr> >>>> + </table> >>>> + </#if> --> >>>> + </td> >>>> + </tr> >>>> +</table> >>>> +</div> >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:eol-style = native >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:keywords = Date Rev Author URL Id >>>> >>>> Propchange: >>>> >>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> svn:mime-type = text/plain >>>> >>>> >>>> >>>> >>> >> > |
Wow very good catch ... Jacques.
Though I never imagine about it :-) BTW I guess Vikas will be more then happy to see himself as like the Ravana :D -- Ashish Vijaywargiya Indore (M.P), India http://en.wikipedia.org/wiki/Indore On Mon, Aug 25, 2008 at 10:07 PM, Jacques Le Roux < [hidden email]> wrote: > Mmm... I see... kind of Ravana > http://fr.wikipedia.org/wiki/Image:Ravana.jpg ? > > I will take care ;o) > > Jacques > > PS : sorry Vikas, I don't know much about Hinduism, and this one seems to > be a demon :/. Anyway it's Ashish's fault :p > > From: "Ashish Vijaywargiya" <[hidden email]> > > Jacques, Do you know Vikas has 10 Eyes :D ? >> >> -- >> Ashish Vijaywargiya >> Indore (M.P), India >> http://en.wikipedia.org/wiki/Indore >> >> >> >> >> On Thu, Aug 21, 2008 at 4:05 PM, Jacques Le Roux < >> [hidden email]> wrote: >> >> Wooow, hard to find :D >>> >>> Jacques >>> >>> From: "Vikas Mayur" <[hidden email]> >>> >>> On Thu, Aug 14, 2008 at 2:07 PM, <[hidden email]> wrote: >>> >>>> >>>> Author: bibryam >>>> >>>>> Date: Thu Aug 14 01:37:52 2008 >>>>> New Revision: 685809 >>>>> >>>>> URL: http://svn.apache.org/viewvc?rev=685809&view=rev >>>>> Log: >>>>> Missed these files in my previous commit. >>>>> >>>>> Added: >>>>> >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> (with props) >>>>> >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> (with props) >>>>> >>>>> Added: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> URL: >>>>> >>>>> >>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy?rev=685809&view=auto >>>>> >>>>> >>>>> >>>>> ============================================================================== >>>>> --- >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> (added) >>>>> +++ >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> Thu Aug 14 01:37:52 2008 >>>>> @@ -0,0 +1,311 @@ >>>>> +/* >>>>> + * 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.lang.*; >>>>> +import java.util.*; >>>>> +import java.text.NumberFormat; >>>>> +import org.ofbiz.base.util.*; >>>>> +import org.ofbiz.service.*; >>>>> +import org.ofbiz.entity.*; >>>>> +import org.ofbiz.entity.condition.*; >>>>> +import org.ofbiz.entity.util.*; >>>>> +import org.ofbiz.webapp.taglib.*; >>>>> +import org.ofbiz.webapp.stats.VisitHandler; >>>>> +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; >>>>> +import org.ofbiz.product.catalog.*; >>>>> +import org.ofbiz.product.category.*; >>>>> +import org.ofbiz.product.product.ProductWorker; >>>>> +import org.ofbiz.product.product.ProductContentWrapper; >>>>> +import org.ofbiz.product.product.ProductSearch; >>>>> +import org.ofbiz.product.product.ProductSearchSession; >>>>> +import org.ofbiz.product.store.*; >>>>> + >>>>> +inlineProductId = request.getAttribute("inlineProductId"); >>>>> +inlineCounter = request.getAttribute("inlineCounter"); >>>>> +context.inlineCounter = inlineCounter; >>>>> +context.inlineProductId = inlineProductId; >>>>> + >>>>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>>>> +catalogName = CatalogWorker.getCatalogName(request); >>>>> +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); >>>>> + >>>>> +if (inlineProductId) { >>>>> + inlineProduct = delegator.findByPrimaryKeyCache("Product", >>>>> [productId >>>>> : inlineProductId]); >>>>> + if (inlineProduct) { >>>>> + context.product = inlineProduct; >>>>> + contentWrapper = new ProductContentWrapper(inlineProduct, >>>>> request); >>>>> + context.put("title", contentWrapper.get("PRODUCT_NAME")); >>>>> + context.put("metaDescription", >>>>> contentWrapper.get("DESCRIPTION")); >>>>> + productTemplate = product.detailScreen; >>>>> + if (productTemplate) { >>>>> + detailScreen = productTemplate; >>>>> + } >>>>> + } >>>>> +} >>>>> + >>>>> +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); >>>>> +if (templatePathPrefix) { >>>>> + detailScreen = templatePathPrefix + detailScreen; >>>>> +} >>>>> +context.detailScreen = detailScreen; >>>>> + >>>>> +String buildNext(Map map, List order, String current, String prefix, >>>>> Map >>>>> featureTypes) { >>>>> + def ct = 0; >>>>> + def buf = new StringBuffer(); >>>>> + buf.append("function listFT" + inlineCounter + current + prefix + >>>>> "() >>>>> { "); >>>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter + current + "\"].options.length = 1;"); >>>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter + current + "\"].options[0] = new Option(\"" + >>>>> featureTypes[current] + "\",\"\",true,true);"); >>>>> + map.each { key, value -> >>>>> + def optValue = null; >>>>> + >>>>> + if (order.indexOf(current) == (order.size()-1)) { >>>>> + optValue = value.iterator().next(); >>>>> + } else { >>>>> + optValue = prefix + "_" + ct; >>>>> + } >>>>> + >>>>> + buf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter + current + "\"].options[" + (ct + 1) + "] = new >>>>> Option(\"" >>>>> + >>>>> key + "\",\"" + optValue + "\");"); >>>>> + ct++; >>>>> + } >>>>> + buf.append(" }"); >>>>> + if (order.indexOf(current) < (order.size()-1)) { >>>>> + ct = 0; >>>>> + map.each { key, value -> >>>>> + def nextOrder = order.get(order.indexOf(current)+1); >>>>> + def newPrefix = prefix + "_" + ct; >>>>> + buf.append(buildNext(value, order, nextOrder, newPrefix, >>>>> featureTypes)); >>>>> + ct++; >>>>> + } >>>>> + } >>>>> + return buf.toString(); >>>>> +} >>>>> + >>>>> +cart = ShoppingCartEvents.getCartObject(request); >>>>> + >>>>> +// set the content path prefix >>>>> +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); >>>>> +context.contentPathPrefix = contentPathPrefix; >>>>> + >>>>> +// get the product detail information >>>>> +if (inlineProduct) { >>>>> + inlineProductId = inlineProduct.productId; >>>>> + productTypeId = inlineProduct.productTypeId; >>>>> + featureTypes = [:]; >>>>> + featureOrder = []; >>>>> + >>>>> + // make the productContentWrapper >>>>> + productContentWrapper = new ProductContentWrapper(inlineProduct, >>>>> request); >>>>> + context.productContentWrapper = productContentWrapper; >>>>> + >>>>> + // get the main detail image (virtual or single product) >>>>> + mainDetailImage = productContentWrapper.get("DETAIL_IMAGE_URL"); >>>>> + if (mainDetailImage) { >>>>> + mainDetailImageUrl = ContentUrlTag.getContentPrefix(request) + >>>>> mainDetailImage; >>>>> + mainDetailImageUrl = >>>>> URLEncoder.encode(Base64.base64Encode(mainDetailImage), "UTF-8"); >>>>> + context.mainDetailImageUrl = mainDetailImageUrl; >>>>> + } >>>>> + >>>>> + >>>>> + // get the product price >>>>> + webSiteId = CatalogWorker.getWebSiteId(request); >>>>> + autoUserLogin = >>>>> request.getSession().getAttribute("autoUserLogin"); >>>>> + if (cart.isSalesOrder()) { >>>>> + // sales order: run the "calculateProductPrice" service >>>>> + priceContext = [product : inlineProduct, prodCatalogId : >>>>> currentCatalogId, >>>>> + currencyUomId : cart.getCurrency(), autoUserLogin : >>>>> autoUserLogin]; >>>>> + priceContext.webSiteId = webSiteId; >>>>> + priceContext.productStoreId = productStoreId; >>>>> + priceContext.checkIncludeVat = "Y"; >>>>> + priceContext.agreementId = cart.getAgreementId(); >>>>> + priceContext.partyId = cart.getPartyId(); // IMPORTANT: must >>>>> put >>>>> this in, or price will be calculated for the CSR instead of the >>>>> customer >>>>> + priceMap = dispatcher.runSync("calculateProductPrice", >>>>> priceContext); >>>>> + context.priceMap = priceMap; >>>>> + } else { >>>>> + // purchase order: run the "calculatePurchasePrice" service >>>>> + priceContext = [product : inlineProduct, currencyUomId : >>>>> cart.getCurrency(), >>>>> + partyId : cart.getPartyId(), userLogin : userLogin]; >>>>> + priceMap = dispatcher.runSync("calculatePurchasePrice", >>>>> priceContext); >>>>> + context.priceMap = priceMap; >>>>> + } >>>>> + >>>>> + >>>>> + context.variantTree = null; >>>>> + context.variantTreeSize = null; >>>>> + context.variantSample = null; >>>>> + context.variantSampleKeys = null; >>>>> + context.variantSampleSize = null; >>>>> + if ("Y".equals(inlineProduct.isVirtual)) { >>>>> + if >>>>> >>>>> >>>>> ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod(delegator, >>>>> inlineProductId))) { >>>>> + context.featureLists = >>>>> ProductWorker.getSelectableProductFeaturesByTypesAndSeq(inlineProduct); >>>>> + } else { >>>>> + featureMap = dispatcher.runSync("getProductFeatureSet", >>>>> [productId : inlineProductId]); >>>>> + featureSet = featureMap.featureSet; >>>>> + if (featureSet) { >>>>> + variantTreeMap = >>>>> dispatcher.runSync("getProductVariantTree", [productId : >>>>> inlineProductId, >>>>> featureOrder : featureSet, productStoreId : productStoreId]); >>>>> + variantTree = variantTreeMap.variantTree; >>>>> + imageMap = variantTreeMap.variantSample; >>>>> + virtualVariant = variantTreeMap.virtualVariant; >>>>> + context.virtualVariant = virtualVariant; >>>>> + if (variantTree) { >>>>> + context.variantTree = variantTree; >>>>> + context.variantTreeSize = variantTree.size(); >>>>> + } >>>>> + if (imageMap) { >>>>> + context.variantSample = imageMap; >>>>> + context.variantSampleKeys = imageMap.keySet(); >>>>> + context.variantSampleSize = imageMap.size(); >>>>> + } >>>>> + context.featureSet = featureSet; >>>>> + >>>>> + if (variantTree) { >>>>> + featureOrder = new LinkedList(featureSet); >>>>> + featureOrder.each { featureKey -> >>>>> + featureValue = >>>>> delegator.findByPrimaryKeyCache("ProductFeatureType", >>>>> [productFeatureTypeId >>>>> : featureKey]); >>>>> + fValue = featureValue.get("description") ?: >>>>> featureValue.productFeatureTypeId; >>>>> + featureTypes[featureKey] = fValue; >>>>> + } >>>>> + } >>>>> + context.featureTypes = featureTypes; >>>>> + context.featureOrder = featureOrder; >>>>> + if (featureOrder) { >>>>> + context.featureOrderFirst = featureOrder[0]; >>>>> + } >>>>> + >>>>> + if (variantTree && imageMap) { >>>>> + jsBuf = new StringBuffer(); >>>>> + jsBuf.append("<script language=\"JavaScript\">"); >>>>> + jsBuf.append("var DET" + inlineCounter + "= new >>>>> Array(" + variantTree.size() + ");"); >>>>> + jsBuf.append("var IMG" + inlineCounter + " = new >>>>> Array(" + variantTree.size() + ");"); >>>>> + jsBuf.append("var OPT" + inlineCounter + " = new >>>>> Array(" + featureOrder.size() + ");"); >>>>> + jsBuf.append("var VIR" + inlineCounter + " = new >>>>> Array(" + virtualVariant.size() + ");"); >>>>> + jsBuf.append("var detailImageUrl" + inlineCounter >>>>> + >>>>> " >>>>> = null;"); >>>>> + featureOrder.eachWithIndex { feature, i -> >>>>> + jsBuf.append("OPT" + inlineCounter + "[" + i + >>>>> "] >>>>> = \"FT" + inlineCounter + feature + "\";"); >>>>> + } >>>>> + virtualVariant.eachWithIndex { variant, i -> >>>>> + jsBuf.append("VIR" + inlineCounter + "[" + i + >>>>> "] >>>>> = \"" + variant + "\";"); >>>>> + } >>>>> + >>>>> + // build the top level >>>>> + topLevelName = featureOrder[0]; >>>>> + jsBuf.append("function list" + inlineCounter + >>>>> topLevelName + "() {"); >>>>> + >>>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter >>>>> + topLevelName + "\"].options.length = 1;"); >>>>> + >>>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter >>>>> + topLevelName + "\"].options[0] = new Option(\"" + >>>>> featureTypes[topLevelName] + "\",\"\",true,true);"); >>>>> + if (variantTree) { >>>>> + featureOrder.each { featureKey -> >>>>> + >>>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter >>>>> + featureKey + "\"].options.length = 1;"); >>>>> + } >>>>> + firstDetailImage = null; >>>>> + firstLargeImage = null; >>>>> + counter = 0; >>>>> + variantTree.each { key, value -> >>>>> + opt = null; >>>>> + if (featureOrder.size() == 1) { >>>>> + opt = value.iterator().next(); >>>>> + } else { >>>>> + opt = counter as String; >>>>> + } >>>>> + // create the variant content wrapper >>>>> + contentWrapper = new >>>>> ProductContentWrapper(imageMap[key], request); >>>>> + >>>>> + // initial image paths >>>>> + detailImage = >>>>> contentWrapper.get("DETAIL_IMAGE_URL") ?: >>>>> productContentWrapper.get("DETAIL_IMAGE_URL"); >>>>> + largeImage = >>>>> contentWrapper.get("LARGE_IMAGE_URL") ?: >>>>> productContentWrapper.get("LARGE_IMAGE_URL"); >>>>> + >>>>> + // full image URLs >>>>> + detailImageUrl = null; >>>>> + largeImageUrl = null; >>>>> + >>>>> + // append the content prefix >>>>> + if (detailImage) { >>>>> + detailImageUrl = >>>>> ContentUrlTag.getContentPrefix(request) + detailImage; >>>>> + // base64 encode the image url for a >>>>> little protection >>>>> + detailImageUrl = >>>>> URLEncoder.encode(Base64.base64Encode(detailImageUrl), "UTF-8"); >>>>> + } >>>>> + if (largeImage) { >>>>> + largeImageUrl = >>>>> ContentUrlTag.getContentPrefix(request) + largeImage; >>>>> + } >>>>> + >>>>> + >>>>> jsBuf.append("document.forms[\"configform\"].elements[\"FT" + >>>>> inlineCounter >>>>> + topLevelName + "\"].options[" + (counter+1) + "] = new Option(\"" + >>>>> key >>>>> + >>>>> "\",\"" + opt + "\");"); >>>>> + jsBuf.append("DET" + inlineCounter + "[" + >>>>> counter + "] = \"" + detailImageUrl +"\";"); >>>>> + jsBuf.append("IMG" + inlineCounter + "[" + >>>>> counter + "] = \"" + largeImageUrl +"\";"); >>>>> + >>>>> + if (!firstDetailImage) { >>>>> + firstDetailImage = detailImageUrl; >>>>> + } >>>>> + if (!firstLargeImage) { >>>>> + firstLargeImage = largeImage; >>>>> + } >>>>> + counter++; >>>>> + } >>>>> + context.firstDetailImage = firstDetailImage; >>>>> + context.firstLargeImage = firstLargeImage; >>>>> + } >>>>> + jsBuf.append("}"); >>>>> + >>>>> + // build dynamic lists >>>>> + if (variantTree) { >>>>> + variantTree.values().eachWithIndex { varTree, >>>>> topLevelKeysCt -> >>>>> + cnt = "" + topLevelKeysCt; >>>>> + if (varTree instanceof Map) { >>>>> + jsBuf.append(buildNext(varTree, >>>>> featureOrder, featureOrder[1], cnt, featureTypes)); >>>>> + } >>>>> + } >>>>> + } >>>>> + >>>>> + // make a list of variant sku with requireAmount >>>>> + variantsRes = >>>>> dispatcher.runSync("getAssociatedProducts", [productId : >>>>> inlineProductId, >>>>> type : "PRODUCT_VARIANT", checkViewAllow : true, prodCatalogId : >>>>> currentCatalogId]); >>>>> + variants = variantsRes.assocProducts; >>>>> + if (variants) { >>>>> + amt = new StringBuffer(); >>>>> + amt.append("function checkAmtReq" + >>>>> inlineCounter >>>>> + "(sku) { "); >>>>> + // Create the javascript to return the price >>>>> for >>>>> each variant >>>>> + variantPriceJS = new StringBuffer(); >>>>> + variantPriceJS.append("function >>>>> getVariantPrice" >>>>> + >>>>> inlineCounter + "(sku) { "); >>>>> + // Format to apply the currency code to the >>>>> variant price in the javascript >>>>> + productStore = >>>>> ProductStoreWorker.getProductStore(request); >>>>> + localeString = >>>>> productStore.defaultLocaleString; >>>>> + if (localeString) { >>>>> + locale = >>>>> UtilMisc.parseLocale(localeString); >>>>> + } >>>>> + numberFormat = >>>>> NumberFormat.getCurrencyInstance(locale); >>>>> + variants.each { variantAssoc -> >>>>> + variant = >>>>> variantAssoc.getRelatedOne("AssocProduct"); >>>>> + // Get the price for each variant. Reuse >>>>> the >>>>> priceContext already setup for virtual product above and replace the >>>>> product >>>>> + if (cart.isSalesOrder()) { >>>>> + // sales order: run the >>>>> "calculateProductPrice" service >>>>> + priceContext.product = variant; >>>>> + variantPriceMap = >>>>> dispatcher.runSync("calculateProductPrice", priceContext); >>>>> + } >>>>> + amt.append(" if (sku == \"" + >>>>> variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + >>>>> "\"; >>>>> "); >>>>> + variantPriceJS.append(" if (sku == \"" + >>>>> variant.productId + "\") return \"" + >>>>> numberFormat.format(variantPriceMap.basePrice) + "\"; "); >>>>> + } >>>>> + amt.append(" } "); >>>>> + variantPriceJS.append(" } "); >>>>> + } >>>>> + jsBuf.append(amt.toString()); >>>>> + jsBuf.append(variantPriceJS.toString()); >>>>> + jsBuf.append("</script>"); >>>>> + >>>>> + context.virtualJavaScript = jsBuf.toString(); >>>>> + } >>>>> + } >>>>> + } >>>>> + } >>>>> +} >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:eol-style = native >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:keywords = Date Rev Author URL Id >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/InlineProductDetail.groovy >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:mime-type = text/plain >>>>> >>>>> Added: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> URL: >>>>> >>>>> >>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl?rev=685809&view=auto >>>>> >>>>> >>>>> >>>>> ============================================================================== >>>>> --- >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> (added) >>>>> +++ >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> Thu Aug 14 01:37:52 2008 >>>>> @@ -0,0 +1,389 @@ >>>>> +<#-- >>>>> +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. >>>>> +--> >>>>> + >>>>> +${virtualJavaScript?if_exists} >>>>> +<#assign addJavaScript = requestAttributes.addJavaScript/> >>>>> +<#if (addJavaScript == 0)> >>>>> +<script language="JavaScript" type="text/javascript"> >>>>> + >>>>> + function popupDetailInline(inlineCounter) { >>>>> + var imageField = 'detailImage' + inlineCounter; >>>>> + var defaultDetailImage = document.getElementById(imageField); >>>>> + if (defaultDetailImage == null || defaultDetailImage == >>>>> "null") >>>>> { >>>>> + defaultDetailImage = "_NONE_"; >>>>> + } >>>>> + var fieldName = 'detailImageUrl' + inlineCounter; >>>>> + if (window[fieldName] == null || window[fieldName] == "null") >>>>> { >>>>> + window[fieldName] = defaultDetailImage; >>>>> + } >>>>> + >>>>> + if (window[fieldName] == "_NONE_") { >>>>> + alert("No detail image available to display."); >>>>> + return; >>>>> + } >>>>> + popUp("<@ofbizUrl>detailImage?detail=" + window[fieldName] + >>>>> "</@ofbizUrl>", 'detailImage', '400', '550'); >>>>> + } >>>>> + >>>>> + function setAddProductIdInline(inlineCounter, name) { >>>>> + var add_product_id = 'add_product_id' + inlineCounter; >>>>> + var product_id_display = 'product_id_display' + inlineCounter; >>>>> + document.configform[add_product_id].value = name; >>>>> + if (name == '' || name == 'NULL' || >>>>> isVirtualInline(inlineCounter, >>>>> name) == true) { >>>>> + //document.configform.quantity.disabled = true; >>>>> + var elem = document.getElementById(product_id_display); >>>>> + var txt = document.createTextNode(''); >>>>> + if(elem.hasChildNodes()) { >>>>> + elem.replaceChild(txt, elem.firstChild); >>>>> + } else { >>>>> + elem.appendChild(txt); >>>>> + } >>>>> + >>>>> + checkOtion(inlineCounter); >>>>> + } else { >>>>> + //document.configform.quantity.disabled = false; >>>>> + var elem = document.getElementById(product_id_display); >>>>> + var txt = document.createTextNode(name); >>>>> + if(elem.hasChildNodes()) { >>>>> + elem.replaceChild(txt, elem.firstChild); >>>>> + } else { >>>>> + elem.appendChild(txt); >>>>> + } >>>>> + } >>>>> + } >>>>> + >>>>> + function checkOtion(inlineCounter) { >>>>> >>>>> >>>> >>>> I think it would be "checkOption" grammatically - but its not a big >>>> concern >>>> :) >>>> >>>> - Vikas >>>> >>>> >>>> + var option = >>>> document.getElementById(inlineCounter.substring(0, >>>> >>>>> inlineCounter.length - 2)); >>>>> + if (option.checked) { >>>>> + option.checked=false; >>>>> + } >>>>> + } >>>>> + >>>>> + function setVariantPriceInline(inlineCounter, sku) { >>>>> + var variant_price_display = 'variant_price_display' + >>>>> inlineCounter; >>>>> + if (sku == '' || sku == 'NULL' || >>>>> isVirtualInline(inlineCounter, >>>>> sku) == true) { >>>>> + var elem = document.getElementById(variant_price_display); >>>>> + var txt = document.createTextNode(''); >>>>> + if(elem.hasChildNodes()) { >>>>> + elem.replaceChild(txt, elem.firstChild); >>>>> + } else { >>>>> + elem.appendChild(txt); >>>>> + } >>>>> + } >>>>> + else { >>>>> + var elem = document.getElementById(variant_price_display); >>>>> + var functionName = 'getVariantPrice' + inlineCounter; >>>>> + var price = window[functionName](sku); >>>>> + var txt = document.createTextNode('+' + price); >>>>> + if(elem.hasChildNodes()) { >>>>> + elem.replaceChild(txt, elem.firstChild); >>>>> + } else { >>>>> + elem.appendChild(txt); >>>>> + } >>>>> + } >>>>> + } >>>>> + function isVirtualInline(inlineCounter, product) { >>>>> + var isVirtual = false; >>>>> + var fieldName = 'VIR' + inlineCounter; >>>>> + <#if virtualJavaScript?exists> >>>>> + for (i = 0; i < window[fieldName].length; i++) { >>>>> + if (window[fieldName][i] == product) { >>>>> + isVirtual = true; >>>>> + } >>>>> + } >>>>> + </#if> >>>>> + return isVirtual; >>>>> + } >>>>> + >>>>> + function toggleAmtInline(inlineCounter, toggle) { >>>>> + var fieldName = 'add_amount' + inlineCounter; >>>>> + if (toggle == 'Y') { >>>>> + changeObjectVisibility(fieldName, "visible"); >>>>> + } >>>>> + >>>>> + if (toggle == 'N') { >>>>> + changeObjectVisibility(fieldName, "hidden"); >>>>> + } >>>>> + } >>>>> + >>>>> + function findIndexInline(varname, name ) { >>>>> + for (i = 0; i < window[varname].length; i++) { >>>>> + if ( window[varname][i] == name) { >>>>> + return i; >>>>> + } >>>>> + } >>>>> + return -1; >>>>> + } >>>>> + >>>>> + function checkOptionToggle(inlineCounter, disable) { >>>>> + var index = inlineCounter.indexOf('_'); >>>>> + var optionElementName = inlineCounter.substring(0,index); >>>>> + var option = document.getElementById(optionElementName); >>>>> + if ("true" == disable) { >>>>> + option.disabled = true; >>>>> + if (option.checked == true) { >>>>> + option.checked == false; >>>>> + } >>>>> + } else { >>>>> + //check all virtual product for the option >>>>> + } >>>>> + } >>>>> + >>>>> + function checkOptionVariants(optionName) { >>>>> + var option = document.getElementById(optionName); >>>>> + if (option.checked == false) { >>>>> + return false; >>>>> + } >>>>> + >>>>> + var fieldName = "add_product_id" + optionName + "_"; >>>>> + var index = 15 + optionName.toString().length; >>>>> + var cform = document.forms["configform"]; >>>>> + var len = cform.elements.length; >>>>> + for (var i = 0; i < len; i++) { >>>>> + var element = cform.elements[i]; >>>>> + if (element.name.substring(0, index) == fieldName) { >>>>> + if (element.value == '' || element.value == 'NULL') { >>>>> + option.checked = false; >>>>> + alert('Please select all features first'); >>>>> + return false; >>>>> + } >>>>> + } >>>>> + } >>>>> + } >>>>> + >>>>> + function getListInline(inlineCounter, name, index, src) { >>>>> + currentFeatureIndex = findIndexInline('OPT'+inlineCounter, >>>>> name); >>>>> + >>>>> + if (currentFeatureIndex == 0) { >>>>> + // set the images for the first selection >>>>> + if ([index] != null) { >>>>> + if (document.images['mainImage'+ inlineCounter] != >>>>> null) >>>>> { >>>>> + document.images['mainImage'+ inlineCounter].src = >>>>> window['IMG'+ inlineCounter][index]; >>>>> + window['detailImageUrl'+ inlineCounter] = >>>>> window['DET'+ inlineCounter][index]; >>>>> + } >>>>> + } >>>>> + >>>>> + // set the drop down index for swatch selection >>>>> + document.forms["configform"].elements[name].selectedIndex >>>>> = >>>>> (index*1)+1; >>>>> + } >>>>> + >>>>> + if (currentFeatureIndex < (window['OPT'+ >>>>> inlineCounter].length-1)) >>>>> { >>>>> + // eval the next list if there are more >>>>> + var selectedValue = >>>>> document.forms["configform"].elements[name].options[(index*1)+1].value; >>>>> + if (index == -1) { >>>>> + var featureOrderFirst = window['OPT'+ >>>>> inlineCounter][(currentFeatureIndex)].toString(); >>>>> + var length = featureOrderFirst.length; >>>>> + featureOrderFirst = featureOrderFirst.substring(2, >>>>> length); >>>>> + var Variable1 = eval("list" + featureOrderFirst + >>>>> "()"); >>>>> + } else { >>>>> + var Variable1 = eval("list" + window['OPT'+ >>>>> inlineCounter][(currentFeatureIndex+1)] + selectedValue + "()"); >>>>> + } >>>>> + >>>>> + // set the product ID to NULL to trigger the alerts >>>>> + setAddProductIdInline(inlineCounter, 'NULL'); >>>>> + >>>>> + // set the variant price to NULL >>>>> + setVariantPriceInline(inlineCounter, 'NULL'); >>>>> + >>>>> + //checkOptionToggle(inlineCounter, 'false'); >>>>> + } else { >>>>> + // this is the final selection -- locate the selected >>>>> index >>>>> of >>>>> the last selection >>>>> + var indexSelected = >>>>> document.forms["configform"].elements[name].selectedIndex; >>>>> + >>>>> + // using the selected index locate the sku >>>>> + var sku = >>>>> >>>>> document.forms["configform"].elements[name].options[indexSelected].value; >>>>> + >>>>> + // set the product ID >>>>> + setAddProductIdInline(inlineCounter, sku); >>>>> + >>>>> + // set the variant price >>>>> + setVariantPriceInline(inlineCounter, sku); >>>>> + >>>>> + // check for amount box >>>>> + var functionName = 'checkAmtReq' + inlineCounter; >>>>> + toggleAmtInline(inlineCounter, window[functionName](sku)); >>>>> + >>>>> + //checkOptionToggle(inlineCounter, 'true'); >>>>> + } >>>>> + } >>>>> + >>>>> + >>>>> + </script> >>>>> +</#if> >>>>> + >>>>> +<#assign addedFeatureTreeJavaScript = >>>>> requestAttributes.addedFeatureTreeJavaScript?default("N")/> >>>>> +<#if product.virtualVariantMethodEnum?if_exists == "VV_FEATURETREE" && >>>>> featureLists?has_content && ("N" == addedFeatureTreeJavaScript)> >>>>> + ${setRequestAttribute("addedFeatureTreeJavaScript", "Y")} >>>>> + <script language="JavaScript" type="text/javascript"> >>>>> + function checkRadioButtoninline(inlineCounter, productId) { >>>>> + var add_product_id = 'add_product_id' + inlineCounter; >>>>> + <#list featureLists as featureList> >>>>> + <#list featureList as feature> >>>>> + <#if feature_index == 0> >>>>> + var myList = document.getElementById("FT" >>>>> +inlineCounter + "${feature.productFeatureTypeId}"); >>>>> + if (myList.options[0].selected == true) { >>>>> + document.configform[add_product_id].value >>>>> = >>>>> 'NULL'; >>>>> + return; >>>>> + } >>>>> + <#break> >>>>> + </#if> >>>>> + </#list> >>>>> + </#list> >>>>> + document.configform[add_product_id].value = productId; >>>>> + } >>>>> + </script> >>>>> +</#if> >>>>> + >>>>> + >>>>> +<#assign price = priceMap?if_exists/> >>>>> +<div id="inlineproductdetail${inlineCounter}"> >>>>> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> >>>>> + <tr> >>>>> + <td align="left" valign="top" width="0"> >>>>> + <#assign productLargeImageUrl = >>>>> productContentWrapper.get("LARGE_IMAGE_URL")?if_exists> >>>>> + <#if firstLargeImage?has_content> >>>>> + <#assign productLargeImageUrl = firstLargeImage> >>>>> + </#if> >>>>> + <#if productLargeImageUrl?has_content> >>>>> + <input type="hidden" name="detailImage${inlineCounter}" >>>>> >>>>> >>>>> value="${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}"/> >>>>> + <a >>>>> href="javascript:popupDetailInline('${inlineCounter}');"><img >>>>> >>>>> >>>>> src='<@ofbizContentUrl>${contentPathPrefix?if_exists}${productLargeImageUrl?if_exists}</@ofbizContentUrl>' >>>>> name='mainImage${inlineCounter}' vspace='5' hspace='5' border='0' >>>>> width='100' align='left'></a> >>>>> + </#if> >>>>> + </td> >>>>> + <td align="right" valign="top" width="100%"> >>>>> + <#-- >>>>> <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2> --> >>>>> + <#assign inStock = true> >>>>> + <#if product.isVirtual?if_exists?upper_case == "Y"> >>>>> + <#if product.virtualVariantMethodEnum?if_exists == >>>>> "VV_FEATURETREE" && featureLists?has_content> >>>>> + <#list featureLists as featureList> >>>>> + <#list featureList as feature> >>>>> + <#if feature_index == 0> >>>>> + <div>${feature.description}: <select >>>>> id="FT${inlineCounter}${feature.productFeatureTypeId}" >>>>> name="FT${inlineCounter}${feature.productFeatureTypeId}" >>>>> onChange="javascript:checkRadioButtoninline('${inlineCounter}', >>>>> '${product.productId}');"> >>>>> + <option value="select" selected="selected"> >>>>> select >>>>> option </option> >>>>> + <#else> >>>>> + <option >>>>> value="${feature.productFeatureId}">${feature.description} <#if >>>>> feature.price?exists>(+ <@ofbizCurrency amount=feature.price?string >>>>> isoCode=feature.currencyUomId/>)</#if></option> >>>>> + </#if> >>>>> + </#list> >>>>> + </select> >>>>> + </div> >>>>> + </#list> >>>>> + <input type="hidden" name="product_id${inlineCounter}" >>>>> value="${product.productId}"/> >>>>> + <input type="hidden" >>>>> name="add_product_id${inlineCounter}" >>>>> value="NULL"/> >>>>> + </#if> >>>>> + <#if !product.virtualVariantMethodEnum?exists || >>>>> product.virtualVariantMethodEnum == "VV_VARIANTTREE"> >>>>> + <#if variantTree?exists && (variantTree.size() > 0)> >>>>> + <#list featureSet as currentType> >>>>> + <div> >>>>> + <select name="FT${inlineCounter}${currentType}" >>>>> onchange="javascript:getListInline('${inlineCounter}', this.name, >>>>> (this.selectedIndex-1), 1);"> >>>>> + <option>${featureTypes.get(currentType)}</option> >>>>> + </select> >>>>> + </div> >>>>> + </#list> >>>>> + <input type="hidden" name="product_id${inlineCounter}" >>>>> value="${product.productId}"/> >>>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>>> value="NULL"/> >>>>> + <div> >>>>> + <b><span id="product_id_display${inlineCounter}"> >>>>> </span></b> >>>>> + <b><div id="variant_price_display${inlineCounter}"> >>>>> </div></b> >>>>> + </div> >>>>> + <#else> >>>>> + <input type="hidden" name="product_id${inlineCounter}" >>>>> value="${product.productId}"/> >>>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>>> value="NULL"/> >>>>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>>>> + <#assign inStock = false> >>>>> + </#if> >>>>> + </#if> >>>>> + <#else> >>>>> + <input type="hidden" name="product_id${inlineCounter}" >>>>> value="${product.productId}"/> >>>>> + <input type="hidden" name="add_product_id${inlineCounter}" >>>>> value="${product.productId}"/> >>>>> + <#assign isStoreInventoryNotAvailable = >>>>> >>>>> >>>>> !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, >>>>> product, 1.0?double))> >>>>> + <#assign isStoreInventoryRequired = >>>>> >>>>> >>>>> Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, >>>>> product)> >>>>> + <#if isStoreInventoryNotAvailable> >>>>> + <#if isStoreInventoryRequired> >>>>> + <div><b>${uiLabelMap.ProductItemOutofStock}.</b></div> >>>>> + <#assign inStock = false> >>>>> + <#else> >>>>> + <div><b>${product.inventoryMessage?if_exists}</b></div> >>>>> + </#if> >>>>> + </#if> >>>>> + </#if> >>>>> + </td></tr> >>>>> + <tr><td COLSPAN="2" align="right"> >>>>> + <#-- check to see if introductionDate hasnt passed yet --> >>>>> + <#if product.introductionDate?exists && >>>>> nowTimestamp.before(product.introductionDate)> >>>>> + <p> </p> >>>>> + <div style="color: >>>>> red;">${uiLabelMap.ProductProductNotYetMadeAvailable}.</div> >>>>> + <#-- check to see if salesDiscontinuationDate has passed --> >>>>> + <#elseif product.salesDiscontinuationDate?exists && >>>>> nowTimestamp.after(product.salesDiscontinuationDate)> >>>>> + <div style="color: >>>>> red;">${uiLabelMap.ProductProductNoLongerAvailable}.</div> >>>>> + <#-- check to see if the product requires inventory check and >>>>> has >>>>> inventory --> >>>>> + <#elseif product.virtualVariantMethodEnum?if_exists != >>>>> "VV_FEATURETREE"> >>>>> + <#if inStock> >>>>> + <#if product.requireAmount?default("N") == "Y"> >>>>> + <#assign hiddenStyle = "visible"> >>>>> + <#else> >>>>> + <#assign hiddenStyle = "hidden"> >>>>> + </#if> >>>>> + <div id="add_amount${inlineCounter}" >>>>> class="${hiddenStyle}"> >>>>> + <span style="white-space: >>>>> nowrap;"><b>${uiLabelMap.CommonAmount}:</b></span> >>>>> + <input type="text" size="5" >>>>> name="add_amount${inlineCounter}" value=""/> >>>>> + </div> >>>>> + </#if> >>>>> + </#if> >>>>> + </td></tr> >>>>> + >>>>> + <tr><td COLSPAN="2" align="right"> >>>>> + <#if variantTree?exists && 0 < variantTree.size()> >>>>> + <script language="JavaScript" >>>>> type="text/javascript">eval("list"+ >>>>> "${inlineCounter}" + "${featureOrderFirst}" + "()");</script> >>>>> + </#if> >>>>> + >>>>> + <#-- Swatches (virtual products only) . For now commented out, >>>>> before fixing a bug >>>>> + <#if variantSample?exists && 0 < variantSample.size()> >>>>> + <#assign imageKeys = variantSample.keySet()> >>>>> + <#assign imageMap = variantSample> >>>>> + <p> </p> >>>>> + <table cellspacing="0" cellpadding="0"> >>>>> + <tr> >>>>> + <#assign maxIndex = 7> >>>>> + <#assign indexer = 0> >>>>> + <#list imageKeys as key> >>>>> + <#assign swatchProduct = imageMap.get(key)> >>>>> + <#if swatchProduct?has_content && indexer < maxIndex> >>>>> + <#assign imageUrl = >>>>> >>>>> >>>>> Static["org.ofbiz.product.product.ProductContentWrapper"].getProductContentAsText(swatchProduct, >>>>> "SMALL_IMAGE_URL", request)?if_exists> >>>>> + <#if !imageUrl?has_content> >>>>> + <#assign imageUrl = >>>>> productContentWrapper.get("SMALL_IMAGE_URL")?if_exists> >>>>> + </#if> >>>>> + <#if !imageUrl?has_content> >>>>> + <#assign imageUrl = "/images/defaultImage.jpg"> >>>>> + </#if> >>>>> + <td align="center" valign="bottom"> >>>>> + <a >>>>> href="javascript:getListInline('${inlineCounter}', >>>>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);"><img >>>>> >>>>> >>>>> src="<@ofbizContentUrl>${contentPathPrefix?if_exists}${imageUrl}</@ofbizContentUrl>" >>>>> border="0" width="60" height="60"></a> >>>>> + <br/> >>>>> + <a >>>>> href="javascript:getListInline('${inlineCounter}', >>>>> 'FT${inlineCounter}${featureOrderFirst}','${indexer}',1);" >>>>> class="linktext">${key}</a> >>>>> + </td> >>>>> + </#if> >>>>> + <#assign indexer = indexer + 1> >>>>> + </#list> >>>>> + <#if (indexer > maxIndex)> >>>>> + <div><b>${uiLabelMap.ProductMoreOptions}</b></div> >>>>> + </#if> >>>>> + </tr> >>>>> + </table> >>>>> + </#if> --> >>>>> + </td> >>>>> + </tr> >>>>> +</table> >>>>> +</div> >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:eol-style = native >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:keywords = Date Rev Author URL Id >>>>> >>>>> Propchange: >>>>> >>>>> >>>>> ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/inlineProductDetail.ftl >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> svn:mime-type = text/plain >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>> >> > |
Free forum by Nabble | Edit this page |