<div id="viewPortfolio">

	<div class="breadcrumbRight">&nbsp;</div>
	<div id="breadcrumb" msgid="titleForex">Forex</div>
	
	<div id="masterContent">
		<div id="pageTitle" class="content" msgid="titleForex">Forex</div>
		<div id="date" class="content">
			<table>
				<tr>
					<td class="setDateTd">
						<span class="asOfDate" msgid="publicDate">As of Date</span> 
						<select
							id="forexSelectId" class="AsOfDate dropDownStyle">
							{{each(i,selectDate) app.user.asOfDate}}
						  		<option>${selectDate}</option>
							{{/each}}
						</select>
					</td>
					<td class="tdDateLine">
						<div class="dateLine"></div>
					</td>
				</tr>
			</table>
		</div>
	
	{{if (meta.errorType) != null}}
		<div class="content">The request fail, ErrorMessage:${meta.errorMessage}</div>
	{{else}}
		<div>
			<div id="forexSelectId" class="content">
			{{each(i, portfolioNumber) getKeyArray(data.result.assetPosition)}}
			
			<table id="positionDTable" class="positionDT" style="width:100%">
				<tr>
					<td colspan="8" class="netAssetValueTd">
						<span msgid="publicAccountNumber">Account Number:</span> ${app.selectBpKey}<span style="margin-left: 50px;"></span>
						<span msgid="publicPortfolioNumber">Portfolio Number:</span> ${portfolioNumber}<span style="margin-left: 50px;"></span>
						<span msgid="publicNetAssetValues">Net Asset Value:</span> <span id="netAsset${i}"></span>
						<br/>
						<span msgid="publicPortfolioName">Portfolio Name:</span> ${data.result.portfolio[portfolioNumber].portfolioName}</span>
					</td>
				<tr>
				<tr>
	           		<th style="text-align:left;" class="indent6">
	           			<span msgid="pDetailDescription">Description</span>
	           		</th>
	           		<th></th>
	               	<th>
	               		<span msgid="pDetailBuyCurrencyAmt">Buy Currency/Amt</span>
	               	</th>
	               	<th>
	               		<span msgid="pDetailSellCurrencyAmt">Sell Currency/Amt</span>
	               	</th>
	               	<th>
	               		<span msgid="pDetailExRate">Ex.Rate</span>
	               	</th>
	               	<th>
	               		<span msgid="pDetailTradeDate">TradeDate</span>
	               		<p msgid="pDetailDDMMYYYY" class="smalWord">DD.MM.YYYY</p>
	               	</th>
	               	<th>
	               		<span msgid="pDetailValueDate">Value Date</span>
	               		<p msgid="pDetailDDMMYYYY" class="smalWord">DD.MM.YYYY</p>
	               	</th>
	               	<th>
	               		<span msgid="pDetailReplacement">Replacement</span><br>
	               		<span msgid="pDetailValue">Value</span> (${data.result.portfolio[portfolioNumber].refCcy})
	               	</th>
	        	</tr>
	        	{{each(x, class1Types) getKeyArray(data.result.assetPosition[portfolioNumber])}}
	         			<tr class="category_t1_l1"><td colspan="8" class="class1Category">${class1Types}</td></tr>
		         	{{each(j, types) getKeyArray(data.result.assetPosition[portfolioNumber][class1Types])}}
		         		<tr class="category_t1_l2"><td colspan="8" style="text-align:left;">${types}</td></tr>
		         		{{each(k, typesData) getKeyArray(data.result.assetPosition[portfolioNumber][class1Types][types])}}
		         			{{if k%2==1 }}
			         			<tr class="even">
			         		{{else}}
			         			<tr class="odd">
			         		{{/if}}
		         			<td style="text-align:left;">
			         			<div style="max-width:138px;word-wrap: break-word;overflow:hidden;">
			         				${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].description1}
			         			</div>
		         			</td>
		         			<!-- Logic
		         				The logic for display "Buy USD/SGD"
								if(type=="buy"){
								    display "Buy "+buyCurreny+"/"+sellCurrency
								}else{
								    display "Sell "+sellCurreny+"/"+buyCurrency 
								}
								USD -> buyCurrency
								SGD->sellCurrency
								630.51 ->buyAmt
								-804.53 ->sellAmt
		         			 -->
		         			<td>
		         			 {{if (data.result.assetPosition[portfolioNumber][class1Types][types][typesData].fxTxType) == 'Buy'}}
					         		<span>Buy</span>
					         		<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].buyCurrency}</span>
					         		<span>/</span>
					         		<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].sellCurrency}</span>
					         {{else}}
					         		<span>Sell</span>
					         		<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].sellCurrency}</span>
					         		<span>/</span>
					         		<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].buyCurrency}</span>
					         {{/if}}
					        </td>
		         			<td>
		         				<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].buyCurrency}</span>
		         				<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].buyAmt}</span>
		         			</td>
		         			<td>
		         				<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].sellCurrency}</span>
		         				<span>${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].sellAmt}</span>
		         			</td>
		         			<td>
		         				${formatMoney(data.result.assetPosition[portfolioNumber][class1Types][types][typesData].exRate)}
		         			</td>
		         			<td>
		         				${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].tradeDate}
		         			</td>
		         			<td>
		         				${data.result.assetPosition[portfolioNumber][class1Types][types][typesData].valueDate}
		         			</td>
		         			<td nowrap>
		         				${formatMoney(data.result.assetPosition[portfolioNumber][class1Types][types][typesData].refValue)}
		         			</td>
		         		</tr>
		         		{{/each}}
		         	{{/each}}
		         {{/each}}
	         		<tr class="total">
	         			<td msgid="pDetailTotal" style="font-weight:bold">Total</td>
	         			<td colspan="5"></td>
	         			<td><b></b></td>
	         			<td colspan="2" nowrap>
	         				<p><b>${formatMoney(data.result.portfolio[portfolioNumber].refValueTotal)}</b></p>
	         			</td>
	         		</tr>
	         </table> 
	         {{/each}}
	         
	         {{if getKeyArray(data.result.assetPosition).length == 0}}
	         	<div>There is no record for the selected date</div>
	         {{else}}
	         	<p>&nbsp;</p>
	         	<!-- Notes -->
			 	<div id="notes"></div>
	         {{/if}}
	        
			</div>
		</div><!-- End div tableScrollDiv -->
	{{/if}}
		
		<div class="footer">
			<img src="images/layout/bkg-content-base-right.gif?version=|||xxx|||">
		</div>
	</div>
</div>