Rev 32331 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<style>.table {background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='100px' width='100px'><text transform='translate(20, 100) rotate(-45)' fill='rgb(211,211,211)' font-size='20'>$partnerCode</text></svg>");}</style><div class="col-lg-12"><table class="table table-border table-condensed table-bordered"id="circular-table"><thead>#set($rowspan = 1)#if($allMargins.size() > 0 || $offers.size() > 0)#set($rowspan=2)#end<tr><th rowspan="$rowspan">Model Id</th><th rowspan=$rowspan>Model</th><th rowspan=$rowspan>Type</th><th rowspan=$rowspan>MRP</th><th rowspan=$rowspan>MOP</th><th rowspan=$rowspan>DP</th>#if($sellins.size() > 0)<th colspan="$sellins.size()" style="text-align: center">Sell In</th>#end#if($sellouts.size() > 0)<th colspan="$sellouts.size()" style="text-align: center">Sell Out</th>#end#set($add=0)#if($upgradeOffer)<th rowspan=$rowspan>Upgrade Offer</th>#set($add=1)#end#foreach($offer in $offers)#set($fieldIndex=$velocityCount*2 + (4 + $allMargins.size() + $add))<th data-idx="$fieldIndex" colspan=2 data-offerid="$offer.getId()"><a href="javascript:void(0)"class="mk_partner_view">$offer.getName()</a></th>#end<th rowspan=$rowspan>NLC</th><th rowspan=$rowspan>MOP-DP</th><th rowspan=$rowspan>Total Margin</th><th rowspan=$rowspan>Net % Margin</th></tr>#if($rowspan==2)<tr>#foreach($marginName in $allMargins)<th>$marginName</th>#end#foreach($offer in $offers)<th>Target</th><th>Margin</th>#end</tr>#end</thead><tbody>#foreach($priceCircularItemModel in $priceCircularItemModels )<tr><td>$priceCircularItemModel.getCatalogSummaryModel().getCatalogId()</td><td>$priceCircularItemModel.getCatalogSummaryModel().getModelName() $priceCircularItemModel.getCatalogSummaryModel().getModelNumber()</td><td>$priceCircularItemModel.getCatalogSummaryModel().getCategory()</td><td class="currency">$priceCircularItemModel.getCatalogSummaryModel().getMrp()</td><td class="currency mop"data-value="$priceCircularItemModel.getCatalogSummaryModel().getMop()">$priceCircularItemModel.getCatalogSummaryModel().getMop()</td><td class="currency dp"data-value='$priceCircularItemModel.getCatalogSummaryModel().getDp()'>$priceCircularItemModel.getCatalogSummaryModel().getDp()</td>#foreach($marginName in $allMargins)#if ($priceCircularItemModel.getHeaderSchemeModelsMap().containsKey($marginName))<td class="currency margin"data-value='$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))'>$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))</td>#else<td>-</td>#end#end#if($upgradeOffer)<td class="currency">$priceCircularItemModel.getUpgradeOffer()</td>#end#foreach($slabPayouts in $priceCircularItemModel.getSlabPayouts())#if($slabPayouts && $slabPayouts.size()>0)<td><select class="mk_criteria_slab"data-value='$slabPayouts.entrySet().iterator().next().getValue()'>#foreach($payout in $slabPayouts.entrySet())<option value='$mvcResponseSender.createResponseString($payout.getValue())'>$payout.getKey()onwards</option>#end</select></td><td class="currency margin"data-value='$mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())'>$mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())</td>#else<td> -</td><td> -</td>#end#end<td class="currency netprice">-</td><td class="currency dpmop">-</td><td class="currency totalmargin">-</td><td class="netmargin">-</td></tr>#end</tbody></table></div><div class="offer-margin-container"><div class="modal text-center" id="offerDescription"><div class="modal-dialog modal-lg modal-dialog-scrollable"><div class="modal-content"></div></div></div></div><script type="text/javascript">$(document).ready(function () {$('#circular-table').find('tr').each(function (i, el) {setMargins(el);});#if($priceCircularItemModels.size()>5)priceCircularTable = $('#circular-table').DataTable({"scrollX": true,"bPaginate": true,"bLengthChange": true,"bFilter": true,"bInfo": false,"bAutoWidth": false,"pageLength": 100,lengthMenu: [[100, -1],[100, 'All'],]});#end//setMargins();});$('select.mk_criteria_slab').change(function () {let tdPayout = $(this).closest('td').next();tdPayout.data("value", JSON.parse($(this).val()));console.log("--------" + tdPayout.data('value'));setMargins($(this).closest('tr'));priceCircularTable.draw();});function setMargins(trContainer) {let dp = $(trContainer).find('.dp').data("value");if (dp == undefined) return;let mop = $(trContainer).find('.mop').data('value');let totalMargin = 0;if ($(trContainer).find('.margin').length > 0) {let fixedMargin = 0;let percentageMargin = 0;$(trContainer).find('.margin').each(function (i, ele) {let amountModel = $(ele).data('value');//console.log(amountModel);if (amountModel.amountType == 'FIXED') {if (!amountModel.discount)fixedMargin += amountModel.amount;} else if (amountModel.amountType == 'PERCENTAGE') {percentageMargin += amountModel.amount;}});let effectiveDp = dp - fixedMargin;console.log(fixedMargin);let percentageValue = effectiveDp / (100 + percentageMargin);console.log(percentageValue + "(" + percentageMargin + "%)");$(trContainer).find('.margin').each(function (i, ele) {let amountModel = $(ele).data('value');//console.log(amountModel);if (amountModel.amountType == 'PERCENTAGE') {$(ele).html(numberToComma(percentageValue * amountModel.amount));totalMargin += percentageValue * amountModel.amount;} else {$(ele).html(numberToComma(amountModel.amount));totalMargin += amountModel.amount;}});}let dpmop = mop - dp;let nlc = dp - totalMargin;$(trContainer).find('.netprice').html(numberToComma(nlc));$(trContainer).find('.dpmop').html(numberToComma(dpmop));totalMargin += dpmop;$(trContainer).find('.totalmargin').html(numberToComma(totalMargin));//debugger;$(trContainer).find('.netmargin').html(numberToComma(totalMargin * 100 / (nlc)) + '%');//priceCircularTable.draw();}</script>