<#-- 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. -->

${title}

<#if invalidProductId?exists>
${invalidProductId}
${uiLabelMap.ProductNewFacility}
<#-- Receiving Results --> <#if receivedItems?has_content>

${uiLabelMap.ProductReceiptPurchaseOrder} ${purchaseOrder.orderId}


<#list receivedItems as item>
${uiLabelMap.ProductShipmentId} ${uiLabelMap.ProductReceipt} ${uiLabelMap.CommonDate} ${uiLabelMap.ProductPo} ${uiLabelMap.ProductLine} ${uiLabelMap.ProductProductId} ${uiLabelMap.ProductPerUnitPrice} ${uiLabelMap.CommonRejected} ${uiLabelMap.CommonAccepted}
${item.shipmentId?if_exists} ${item.shipmentItemSeqId?if_exists} ${item.receiptId} ${item.getString("datetimeReceived").toString()} ${item.orderId} ${item.orderItemSeqId} ${item.productId?default("Not Found")} ${item.unitCost?default(0)?string("##0.00")} ${item.quantityRejected?default(0)?string.number} ${item.quantityAccepted?string.number} <#if (item.quantityAccepted?int > 0 || item.quantityRejected?int > 0)> ${uiLabelMap.CommonCancel}


<#-- Single Product Receiving --> <#if requestParameters.initialSelected?exists && product?has_content>
<#-- general request fields --> <#-- special service fields --> <#if purchaseOrder?has_content> <#assign unitCost = firstOrderItem.unitPrice?default(standardCosts.get(firstOrderItem.productId)?default(0))/> <#-- facility location(s) --> <#assign facilityLocations = (product.getRelatedByAnd("ProductFacilityLocation", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", facilityId)))?if_exists/>
  ${uiLabelMap.ProductPurchaseOrder}   ${purchaseOrder.orderId} / ${firstOrderItem.orderItemSeqId} <#if 1 < purchaseOrderItems.size()> (${uiLabelMap.ProductMultipleOrderItemsProduct} - ${purchaseOrderItems.size()}:1 ${uiLabelMap.ProductItemProduct}) <#else> (${uiLabelMap.ProductSingleOrderItemProduct} - 1:1 ${uiLabelMap.ProductItemProduct})
  ${uiLabelMap.ProductProductId}   ${requestParameters.productId?if_exists}
  ${uiLabelMap.ProductProductName}   ${product.internalName?if_exists}
  ${uiLabelMap.ProductProductDescription}   ${product.description?if_exists}
  ${uiLabelMap.ProductItemDescription}  
  ${uiLabelMap.ProductInventoryItemType}  
 
  ${uiLabelMap.ProductFacilityOwner}   <@htmlTemplate.lookupField formName="selectAllForm" name="ownerPartyId" id="ownerPartyId" fieldFormName="LookupPartyName"/>
  ${uiLabelMap.ProductSupplier}  
  ${uiLabelMap.ProductDateReceived}   <#-- [Now] -->
  ${uiLabelMap.ProductFacilityLocation}   <#if facilityLocations?has_content> <#else> <#if parameters.facilityId?exists> <#assign LookupFacilityLocationView="LookupFacilityLocation?facilityId=${facilityId}"> <#else> <#assign LookupFacilityLocationView="LookupFacilityLocation"> <@htmlTemplate.lookupField formName="selectAllForm" name="locationSeqId" id="locationSeqId" fieldFormName="${LookupFacilityLocationView}"/>
  ${uiLabelMap.ProductRejectedReason}  
  ${uiLabelMap.ProductQuantityRejected}  
  ${uiLabelMap.ProductQuantityAccepted}  
  ${uiLabelMap.ProductPerUnitPrice}   <#-- get the default unit cost --> <#if (!unitCost?exists || unitCost == 0.0)><#assign unitCost = standardCosts.get(product.productId)?default(0)/>
 
<#-- Select Shipment Screen --> <#elseif requestParameters.initialSelected?exists && !requestParameters.shipmentId?exists>

${uiLabelMap.ProductSelectShipmentReceive}

<#-- general request fields --> <#list shipments?if_exists as shipment> <#assign originFacility = shipment.getRelatedOneCache("OriginFacility")?if_exists/> <#assign destinationFacility = shipment.getRelatedOneCache("DestinationFacility")?if_exists/> <#assign statusItem = shipment.getRelatedOneCache("StatusItem")/> <#assign shipmentType = shipment.getRelatedOneCache("ShipmentType")/> <#assign shipmentDate = shipment.estimatedArrivalDate?if_exists/>

${shipment.shipmentId} ${shipmentType.get("description",locale)?default(shipmentType.shipmentTypeId?default(""))} ${statusItem.get("description",locale)?default(statusItem.statusId?default("N/A"))} ${(originFacility.facilityName)?if_exists} [${shipment.originFacilityId?if_exists}] ${(destinationFacility.facilityName)?if_exists} [${shipment.destinationFacilityId?if_exists}] ${(shipment.estimatedArrivalDate.toString())?if_exists}

${uiLabelMap.ProductNoSpecificShipment}
 ${uiLabelMap.ProductReceiveSelectedShipment}
<#-- Multi-Item PO Receiving --> <#elseif requestParameters.initialSelected?exists && purchaseOrder?has_content> getConvertedPrice" />
<#-- general request fields --> <#if shipment?has_content> <#assign rowCount = 0/> <#if !purchaseOrderItems?exists || purchaseOrderItems.size() == 0> <#else/> <#list purchaseOrderItems as orderItem> <#assign defaultQuantity = orderItem.quantity - receivedQuantities[orderItem.orderItemSeqId]?double/> <#assign itemCost = orderItem.unitPrice?default(0)/> <#assign salesOrderItem = salesOrderItems[orderItem.orderItemSeqId]?if_exists/> <#if shipment?has_content> <#if shippedQuantities[orderItem.orderItemSeqId]?exists> <#assign defaultQuantity = shippedQuantities[orderItem.orderItemSeqId]?double - receivedQuantities[orderItem.orderItemSeqId]?double/> <#else> <#assign defaultQuantity = 0/> <#if 0 < defaultQuantity> <#assign orderItemType = orderItem.getRelatedOne("OrderItemType")/> <#if shipment?exists && shipment.shipmentId?has_content> <#if salesOrderItem?has_content> <#assign rowCount = rowCount + 1> <#if rowCount == 0> <#else>
${uiLabelMap.ProductNoItemsPoReceive}.

${uiLabelMap.ProductReceivePurchaseOrder} #${purchaseOrder.orderId}

<#if shipment?has_content>

${uiLabelMap.ProductShipmentId} #${shipment.shipmentId}

Set Shipment As Received 
${uiLabelMap.CommonSelectAll}

<#if orderItem.productId?exists> <#assign product = orderItem.getRelatedOneCache("Product")/> <#else> <#-- location(s) --> <#if currencyUomId?default('') != orderCurrencyUomId?default('')> <#else>
${orderItem.orderItemSeqId}: ${product.productId} - ${orderItem.itemDescription?if_exists} : ${product.description?if_exists} ${orderItemType.get("description",locale)} : ${orderItem.itemDescription?if_exists}   ${uiLabelMap.ProductCreateProduct} ${uiLabelMap.ProductLocation}: <#assign facilityLocations = (orderItem.getRelatedByAnd("ProductFacilityLocation", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", facilityId)))?if_exists/> <#if facilityLocations?has_content> <#else> <#if parameters.facilityId?exists> <#assign LookupFacilityLocationView="LookupFacilityLocation?facilityId=${facilityId}"> <#else> <#assign LookupFacilityLocationView="LookupFacilityLocation"> <@htmlTemplate.lookupField formName="selectAllForm" name="locationSeqId_o_${rowCount}" id="locationSeqId_o_${rowCount}" fieldFormName="${LookupFacilityLocationView}"/> ${uiLabelMap.ProductQtyReceived} : "0"<#else>"${defaultQuantity?string.number}"/>
${uiLabelMap.ProductInventoryItemType} :  ${uiLabelMap.ProductRejectionReason} : ${uiLabelMap.ProductQtyRejected} :
${uiLabelMap.OrderQtyOrdered} :
  ${uiLabelMap.ProductFacilityOwner}: ${uiLabelMap.ProductPerUnitPriceOrder}: ${orderCurrencyUomId?if_exists} ${uiLabelMap.ProductPerUnitPriceFacility}: ${currencyUomId?if_exists} ${uiLabelMap.ProductPerUnitPrice}: ${currencyUomId?if_exists}

${uiLabelMap.ProductNoItemsPo} #${purchaseOrder.orderId} ${uiLabelMap.ProductToReceive}.
${uiLabelMap.ProductReturnToReceiving}
${uiLabelMap.ProductReceiveSelectedProduct}
<#-- Initial Screen --> <#else>

${uiLabelMap.ProductReceiveItem}

${uiLabelMap.ProductPurchaseOrderNumber} <@htmlTemplate.lookupField value="${requestParameters.purchaseOrderId?if_exists}" formName="selectAllForm" name="purchaseOrderId" id="purchaseOrderId" fieldFormName="LookupPurchaseOrderHeaderAndShipInfo"/> ${uiLabelMap.ProductLeaveSingleProductReceiving}
${uiLabelMap.ProductProductId} <@htmlTemplate.lookupField value="${requestParameters.productId?if_exists}" formName="selectAllForm" name="productId" id="productId" fieldFormName="LookupProduct"/> ${uiLabelMap.ProductLeaveEntirePoReceiving}
  ${uiLabelMap.ProductReceiveProduct}