Subversion Repositories SmartDukaan

Rev

Rev 32331 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
32844 shampa 1
<style>
2
    .table {
3
        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>");
4
    }
5
</style>
6
 
7
 
8
 
9
 
32331 amit.gupta 10
<div class="col-lg-12">
11
    <table class="table table-border table-condensed table-bordered"
12
           id="circular-table">
13
 
14
        <thead>
15
            #set($rowspan = 1)
16
            #if($allMargins.size() > 0 || $offers.size() > 0)
17
                #set($rowspan=2)
18
            #end
19
 
20
        <tr>
21
            <th rowspan="$rowspan">Model Id</th>
22
            <th rowspan=$rowspan>Model</th>
23
            <th rowspan=$rowspan>Type</th>
24
            <th rowspan=$rowspan>MRP</th>
25
            <th rowspan=$rowspan>MOP</th>
26
            <th rowspan=$rowspan>DP</th>
27
            #if($sellins.size() > 0)
28
                <th colspan="$sellins.size()" style="text-align: center">Sell In</th>
29
            #end
30
            #if($sellouts.size() > 0)
31
                <th colspan="$sellouts.size()" style="text-align: center
32
                ">Sell Out
33
                </th>
34
            #end
35
            #set($add=0)
36
            #if($upgradeOffer)
37
                <th rowspan=$rowspan>Upgrade Offer</th>
38
                #set($add=1)
39
            #end
40
            #foreach($offer in $offers)
41
                #set($fieldIndex=$velocityCount*2 + (4 + $allMargins.size() + $add))
42
                <th data-idx="$fieldIndex" colspan=2 data-offerid="$offer.getId()"><a href="javascript:void(0)"
43
                                                                                      class="mk_partner_view">$offer.getName()</a>
44
                </th>
45
            #end
46
            <th rowspan=$rowspan>NLC</th>
47
            <th rowspan=$rowspan>MOP-DP</th>
48
            <th rowspan=$rowspan>Total Margin</th>
49
            <th rowspan=$rowspan>Net % Margin</th>
50
 
51
        </tr>
52
            #if($rowspan==2)
53
            <tr>
54
                #foreach($marginName in $allMargins)
55
                    <th>$marginName</th>
56
                #end
57
                #foreach($offer in $offers)
58
                    <th>Target</th>
59
                    <th>Margin</th>
60
                #end
61
            </tr>
62
            #end
63
        </thead>
64
        <tbody>
65
            #foreach($priceCircularItemModel in $priceCircularItemModels )
66
            <tr>
67
                <td>$priceCircularItemModel.getCatalogSummaryModel().getCatalogId()</td>
68
                <td>$priceCircularItemModel.getCatalogSummaryModel().getModelName() $priceCircularItemModel.getCatalogSummaryModel().getModelNumber()</td>
69
                <td>$priceCircularItemModel.getCatalogSummaryModel().getCategory()</td>
70
                <td class="currency">$priceCircularItemModel.getCatalogSummaryModel().getMrp()</td>
71
                <td class="currency mop"
72
                    data-value="$priceCircularItemModel.getCatalogSummaryModel().getMop()">$priceCircularItemModel.getCatalogSummaryModel().getMop()</td>
73
                <td class="currency dp"
74
                    data-value='$priceCircularItemModel.getCatalogSummaryModel().getDp()'>$priceCircularItemModel.getCatalogSummaryModel().getDp()</td>
75
                #foreach($marginName in $allMargins)
76
                    #if ($priceCircularItemModel.getHeaderSchemeModelsMap().containsKey($marginName))
77
                        <td class="currency margin"
78
                            data-value='$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))'>$mvcResponseSender.createResponseString($priceCircularItemModel.getHeaderSchemeModelsMap().get($marginName))</td>
79
                    #else
80
                        <td>-</td>
81
                    #end
82
                #end
83
                #if($upgradeOffer)
84
                    <td class="currency">$priceCircularItemModel.getUpgradeOffer()</td>
85
                #end
86
                #foreach($slabPayouts in $priceCircularItemModel.getSlabPayouts())
87
                    #if($slabPayouts && $slabPayouts.size()>0)
88
                        <td>
89
                            <select class="mk_criteria_slab"
90
                                    data-value='$slabPayouts.entrySet().iterator().next().getValue()'>
91
                                #foreach($payout in $slabPayouts.entrySet())
92
                                    <option value='$mvcResponseSender.createResponseString($payout.getValue())'>$payout.getKey()
93
                                        onwards
94
                                    </option>
95
                                #end
96
                            </select>
97
                        </td>
98
                        <td class="currency margin"
99
                            data-value='$mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())'>
100
                            $mvcResponseSender.createResponseString($slabPayouts.values().iterator().next())
101
                        </td>
102
                    #else
103
                        <td> -</td>
104
                        <td> -</td>
105
                    #end
106
                #end
107
                <td class="currency netprice">-</td>
108
                <td class="currency dpmop">-</td>
109
                <td class="currency totalmargin">-</td>
110
                <td class="netmargin">-</td>
111
 
112
            </tr>
113
            #end
114
        </tbody>
115
    </table>
116
</div>
117
 
118
<div class="offer-margin-container">
119
    <div class="modal  text-center" id="offerDescription">
120
        <div class="modal-dialog modal-lg modal-dialog-scrollable">
121
            <div class="modal-content">
122
            </div>
123
        </div>
124
    </div>
125
</div>
126
<script type="text/javascript">
127
    $(document).ready(function () {
128
        $('#circular-table').find('tr').each(function (i, el) {
129
            setMargins(el);
130
        });
131
        #if($priceCircularItemModels.size()>5)
132
            priceCircularTable = $('#circular-table').DataTable({
133
                "scrollX": true,
134
                "bPaginate": true,
135
                "bLengthChange": true,
136
                "bFilter": true,
137
                "bInfo": false,
138
                "bAutoWidth": false,
139
                "pageLength": 100,
140
                lengthMenu: [
141
                    [100, -1],
142
                    [100, 'All'],
143
                ]
144
            });
145
        #end
146
        //setMargins();
147
    });
148
 
149
    $('select.mk_criteria_slab').change(function () {
150
        let tdPayout = $(this).closest('td').next();
151
        tdPayout.data("value", JSON.parse($(this).val()));
152
        console.log("--------" + tdPayout.data('value'));
153
        setMargins($(this).closest('tr'));
154
        priceCircularTable.draw();
155
    });
156
 
157
    function setMargins(trContainer) {
158
        let dp = $(trContainer).find('.dp').data("value");
159
        if (dp == undefined) return;
160
        let mop = $(trContainer).find('.mop').data('value');
161
        let totalMargin = 0;
162
        if ($(trContainer).find('.margin').length > 0) {
163
            let fixedMargin = 0;
164
            let percentageMargin = 0;
165
            $(trContainer).find('.margin').each(function (i, ele) {
166
                let amountModel = $(ele).data('value');
167
                //console.log(amountModel);
168
                if (amountModel.amountType == 'FIXED') {
169
                    if (!amountModel.discount)
170
                        fixedMargin += amountModel.amount;
171
                } else if (amountModel.amountType == 'PERCENTAGE') {
172
                    percentageMargin += amountModel.amount;
173
                }
174
            });
175
            let effectiveDp = dp - fixedMargin;
176
            console.log(fixedMargin);
177
            let percentageValue = effectiveDp / (100 + percentageMargin);
178
            console.log(percentageValue + "(" + percentageMargin + "%)");
179
            $(trContainer).find('.margin').each(function (i, ele) {
180
                let amountModel = $(ele).data('value');
181
                //console.log(amountModel);
182
                if (amountModel.amountType == 'PERCENTAGE') {
183
                    $(ele).html(numberToComma(percentageValue * amountModel.amount));
184
                    totalMargin += percentageValue * amountModel.amount;
185
                } else {
186
                    $(ele).html(numberToComma(amountModel.amount));
187
                    totalMargin += amountModel.amount;
188
                }
189
            });
190
        }
191
        let dpmop = mop - dp;
192
        let nlc = dp - totalMargin;
193
        $(trContainer).find('.netprice').html(numberToComma(nlc));
194
        $(trContainer).find('.dpmop').html(numberToComma(dpmop));
195
        totalMargin += dpmop;
196
        $(trContainer).find('.totalmargin').html(numberToComma(totalMargin));
197
        //debugger;
198
        $(trContainer).find('.netmargin').html(numberToComma(totalMargin * 100 / (nlc)) + '%');
199
        //priceCircularTable.draw();
200
    }
201
 
202
</script>