Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
26674 tejbeer 1
<style>
27875 amit.gupta 2
    .table-striped > tbody > tr:nth-child(odd) > td {
3
        background: white;
4
        background-color: white;
5
    }
6
 
7
    .table-striped > tbody > tr:nth-child(even) > td {
8
        background: white;
9
        background-color: white;
10
    }
11
 
12
    .table-striped > tbody > tr:hover > td,
13
    .table-striped > tbody > tr:hover {
14
        background-color: #e98c8f;
15
        color: white;
16
    }
17
 
18
    .btn:hover {
19
        color: grey;
20
        text-decoration: none;
21
    }
22
 
23
    .btn-primary:hover {
24
        color: grey;
25
        text-decoration: none;
26
    }
27
 
28
    .sale-details {
29
        cursor: pointer;
30
    }
26674 tejbeer 31
</style>
32
 
33
<section class="wrapper">
27875 amit.gupta 34
    <div class="row">
35
        <div class="col-lg-12">
35858 amit 36
            <h3 class="page-header"><i class="icon_document_alt"></i>OFFER HISTORY
37
                <button class="btn btn-success btn-sm" id="publish-all-btn" type="button" style="margin-left:15px;">Publish All</button>
36703 amit 38
                <a class="btn btn-warning btn-sm refresh-offer-cache" href="javascript:void(0)" style="margin-left:5px;">Refresh Cache</a>
35858 amit 39
            </h3>
27875 amit.gupta 40
            <ol class="breadcrumb">
41
                <li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
32381 jai.hind 42
                <li><i class="icon_document_alt"></i>OFFERS</li>
27875 amit.gupta 43
            </ol>
44
        </div>
45
    </div>
46
 
47
    <table style="Width:100%">
48
 
49
        <td align="left" style="Width:20%">
26719 tejbeer 50
        </td>
27875 amit.gupta 51
 
26719 tejbeer 52
        <td style="Width:80%">
27875 amit.gupta 53
            <div id="offer-search">
54
                <div class="row">
55
                    <div class="col-lg-12">
35858 amit 56
                    <div class="col-md-3 col-sm-3 col-xs-12 form-group pull-right top_search">
32381 jai.hind 57
                            <div class="input-group">
58
                                            <span class="input-group-btn">
59
                                         <button class="btn btn-primary submit" id="offer-file-submit" type="button">Add Offers Using Targets</button>
60
                             	</span>
61
                            	</div>
62
                       </div>
27875 amit.gupta 63
                        <div class="col-md-3 col-sm-3 col-xs-12 form-group pull-right top_search">
64
                            <div class="input-group">
29680 amit.gupta 65
                                <input type="file" class="form-control" id="offer-file"
32349 amit.gupta 66
                                       placeholder="Upload Target Offers"/>
32381 jai.hind 67
 
29680 amit.gupta 68
                            </div>
69
                        </div>
32381 jai.hind 70
 
29680 amit.gupta 71
                        <div class="col-md-3 col-sm-3 col-xs-12 form-group pull-right top_search">
72
                            <div class="input-group">
27875 amit.gupta 73
                                <input type="month" class="form-control" id="yearmonth"
30651 amit.gupta 74
                                       placeholder="YYYY-MM"/>
27875 amit.gupta 75
                                <span class="input-group-btn">
30651 amit.gupta 76
                      				<button class="btn btn-primary submit" id="yearmonth-submit"
77
                                            type="button">Go!</button>
29680 amit.gupta 78
                    			</span>
27875 amit.gupta 79
                            </div>
80
                        </div>
81
                    </div>
26719 tejbeer 82
                </div>
27875 amit.gupta 83
            </div>
84
        </td>
85
    </table>
86
    <div id="offer-listings-table">
87
        <div class="row">
88
            <div class="col-lg-12">
37794 ranu 89
                <!-- Offer & Scheme Radar: bulk-select offers to send a WhatsApp
90
                     digest to HO users (RBMs / sales). Backed by
91
                     OfferRadarNotificationController#sendRadarNotification. -->
92
                <div class="offer-radar-bar" style="display:flex; align-items:center; gap:12px; margin-bottom:10px;">
93
                    <button type="button"
94
                            id="offerRadarSendBtn"
95
                            class="btn btn-primary"
96
                            data-radar-kind="offer"
97
                            disabled>
98
                        Send WhatsApp Radar (<span id="offerRadarSelectedCount">0</span>)
99
                    </button>
100
                    <span class="text-muted" style="font-size:12px;">
101
                        Tick any offers below, then send. Recipients: all HO users with a mobile number.
102
                    </span>
103
                </div>
27875 amit.gupta 104
                <table class="table table-striped table-advance table-hover">
105
                    <tbody>
106
                    <tr>
37794 ranu 107
                        <th style="width:28px;">
108
                            <input type="checkbox" id="offerRadarSelectAll" title="Select all">
109
                        </th>
27875 amit.gupta 110
                        <th>Id</th>
111
                        <th>Name</th>
36452 amit 112
                        <th>Reference</th>
28556 amit.gupta 113
                        <th>Payout Type</th>
27875 amit.gupta 114
                        <th>Scheme Type</th>
32027 amit.gupta 115
                        <th>Discount</th>
27875 amit.gupta 116
                        <th>Partner Criteria</th>
117
                        <th>Item Criteria</th>
118
                        <th>Start</th>
119
                        <th>End</th>
120
                        <th>Created</th>
31605 amit.gupta 121
                        <th>Processed</th>
27875 amit.gupta 122
                        <th>Actions</th>
123
                    </tr>
30651 amit.gupta 124
                        #if(!$offers.isEmpty())
125
                            #foreach( $offer in $offers )
126
                            <tr class="offer-details" data-offerid="$offer.getId()" data-offer-title="">
37794 ranu 127
                                <td>
128
                                    <input type="checkbox"
129
                                           class="offer-radar-check"
130
                                           value="$offer.getId()">
131
                                </td>
35745 amit 132
                                <td><a class="mk_offer_detail" href="javascript:void(0)">$offer.getId()</a></td>
30651 amit.gupta 133
                                <td><a class="mk_partner_view" href="javascript:void(0)">$offer.getName()</a></td>
36452 amit 134
                                <td>#if($offer.getReference())$offer.getReference()#else-#end</td>
30651 amit.gupta 135
                                <td>$offer.getPayoutType()</td>
136
                                <td>$offer.getSchemeType()</td>
32027 amit.gupta 137
                                <td>
138
                                    #if ($offer.isDiscount())
139
                                        Discount
140
                                    #else
141
                                        Non Discount
142
                                    #end
143
                                </td>
30651 amit.gupta 144
                                <td>$offer.getPartnerCriteriaString()</td>
145
                                <td>$offer.getItemCriteriaString()</td>
146
                                <td>$offer.getStartDate().format($dateFormatter)</td>
147
                                <td>$offer.getEndDate().format($dateFormatter)</td>
148
                                <td>$offer.getCreatedOn().format($dateTimeFormatter)</td>
31608 amit.gupta 149
                                #if($offer.getProcessTimestamp())
36522 amit 150
                                    <td class="processed-timestamp">$offer.getProcessTimestamp().format($dateTimeFormatter)</td>
31605 amit.gupta 151
                                #else
36522 amit 152
                                    <td class="processed-timestamp"> -</td>
31605 amit.gupta 153
                                #end
30651 amit.gupta 154
                                <td>
155
                                    <ul>
156
                                        <li>
157
                                            #if($offer.isActive())
158
                                                <a class="mk_offer_inactive" href="javascript:void(0)">Mark Inactive</a>
159
                                            #else
160
                                                <a class="mk_offer_active" href="javascript:void(0)">Mark Active</a>
161
                                            #end
162
                                        </li>
163
                                        <li><a href="/offerDownload?offerId=$offer.getId()">Download
164
                                            Report</a></li>
30729 amit.gupta 165
                                        <li><a class="process_offer" href="javascript:void(0)">Process Offer</a>
166
                                        </li>
35886 amit 167
                                        <li><a class="manage_offer_partners" href="javascript:void(0)">Manage Partners</a></li>
35857 amit 168
                                        #if(!$offer.isActive())
169
                                        <li><a class="delete_offer" href="javascript:void(0)" style="color:red;">Delete</a></li>
170
                                        #end
30651 amit.gupta 171
                                        #if(!$currentMonth)
172
                                        #end
173
                                    </ul>
174
                                </td>
175
                            </tr>
176
                            #end
177
                        #else
178
                        <tr>
37794 ranu 179
                            <td colspan="14" style="text-align:center;">NO MATCHING DATA FOUND FOR CRITERIA</td>
30651 amit.gupta 180
                        </tr>
181
                        #end
27875 amit.gupta 182
                    </tbody>
183
                </table>
184
            </div>
26719 tejbeer 185
        </div>
26674 tejbeer 186
    </div>
27875 amit.gupta 187
 
30651 amit.gupta 188
    <div class="modal" id="offerDescription">
189
        <div class="modal-dialog modal-lg">
190
            <div class="modal-content">
191
            </div>
192
        </div>
193
    </div>
27875 amit.gupta 194
</section>
195
 
196
<script type="text/javascript">
30651 amit.gupta 197
    $(function () {
198
        $("#offerDescription").modal('hide');
199
        $('#offerDescription').on('hide.bs.modal', function () {
200
            $(this).find(".modal-content").html("");
201
        });
202
        $("#offer-file-submit").on('click', function () {
203
            var fileSelector = $('#offer-file')[0];
204
            if (fileSelector != undefined && fileSelector.files[0] != undefined) {
205
                if (confirm("Confirm Upload?")) {
206
                    doAjaxUploadRequestHandler(context + "/offers/upload",
207
                            "POST", fileSelector.files[0], function (
208
                                    response) {
209
                                if (response) {
210
                                    alert("Offer added successfully");
211
                                    loadOfferHistory('#main-content', moment(new Date()).format("YYYY-MM"));
212
                                }
213
                            });
214
                }
215
            } else {
216
                alert("Please upload file");
217
            }
218
        });
37794 ranu 219
 
220
        // ── Offer Radar bulk-send wiring ──────────────────────────────
37795 ranu 221
        // jQuery locals are renamed off the conventional $-prefix so Velocity
222
        // never sees a $ident.method() shape and tries to parse it as a
223
        // template reference. Keeps this block readable to any Velocity version
224
        // without needing the whitespace-sensitive #[[ ... ]]# literal block.
225
        var radarSelectAll = $("#offerRadarSelectAll");
226
        var radarBtn = $("#offerRadarSendBtn");
227
        var radarCount = $("#offerRadarSelectedCount");
37794 ranu 228
 
229
        function selectedOfferIds() {
230
            var ids = [];
231
            $(".offer-radar-check:checked").each(function () {
232
                var v = parseInt(this.value, 10);
233
                if (!isNaN(v)) ids.push(v);
234
            });
235
            return ids;
236
        }
237
 
238
        function refreshRadarUi() {
239
            var ids = selectedOfferIds();
37795 ranu 240
            radarCount.text(ids.length);
241
            radarBtn.prop("disabled", ids.length === 0);
37794 ranu 242
            var total = $(".offer-radar-check").length;
243
            var picked = ids.length;
37795 ranu 244
            radarSelectAll.prop("indeterminate", picked > 0 && picked < total);
245
            radarSelectAll.prop("checked", picked > 0 && picked === total);
37794 ranu 246
        }
247
 
37795 ranu 248
        radarSelectAll.on("change", function () {
37794 ranu 249
            $(".offer-radar-check").prop("checked", this.checked);
250
            refreshRadarUi();
251
        });
252
        $(document).on("change", ".offer-radar-check", refreshRadarUi);
253
 
37795 ranu 254
        radarBtn.on("click", function () {
37794 ranu 255
            var ids = selectedOfferIds();
256
            if (ids.length === 0) return;
257
            if (!confirm("Send WhatsApp Radar digest for " + ids.length + " offer(s) to all HO users?")) return;
258
 
37795 ranu 259
            var radarSelf = $(this);
260
            radarSelf.prop("disabled", true).text("Sending…");
37794 ranu 261
            $.ajax({
262
                url: "/offerRadar/sendNotification",
263
                method: "POST",
264
                contentType: "application/json",
265
                data: JSON.stringify({offerIds: ids, schemeIds: []})
266
            }).done(function (resp) {
267
                var r = (resp && resp.response) || resp || {};
268
                alert("Sent to " + (r.sent || 0) + " user(s). Skipped: " + (r.skipped || 0)
269
                        + ", Failed: " + (r.failed || 0)
270
                        + "\nRegion: " + (r.regionSummary || "-")
271
                        + " | Offers added: " + (r.offersAdded || 0)
272
                        + " | Schemes added: " + (r.schemesAdded || 0)
273
                        + " | Revisions: " + (r.revisions || 0)
274
                        + " | Ending soon: " + (r.endingSoon || 0));
275
            }).fail(function (xhr) {
276
                var msg = (xhr.responseJSON && (xhr.responseJSON.response || xhr.responseJSON.message)) || xhr.statusText;
277
                alert("Radar send failed: " + msg);
278
            }).always(function () {
37795 ranu 279
                radarSelf.html('Send WhatsApp Radar (<span id="offerRadarSelectedCount">' + ids.length + '</span>)');
37794 ranu 280
                refreshRadarUi();
281
            });
282
        });
283
 
284
        refreshRadarUi();
30651 amit.gupta 285
    });
27875 amit.gupta 286
</script>
287
 
26719 tejbeer 288
 
289