Subversion Repositories SmartDukaan

Rev

Rev 4793 | Rev 5203 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2749 vikas 1
var orderTable;
2
var cartTable;
3096 mandeep.dh 3
 
3090 mandeep.dh 4
function loadUserPane(domId, userId) {
3228 mandeep.dh 5
    $.ajax({
6
        type : "GET",
7
        url : "/crm/user-info?userId=" + userId,
8
        success : function(response) {
9
            $('#' + domId).html(response);
10
        }
11
    });
2674 vikas 12
}
13
 
3228 mandeep.dh 14
function loadOrderPane(domId, userId, orderId) {
15
    $.ajax({
16
        type : "GET",
17
        url : "/crm/user-orders?userId=" + userId,
18
        success : function(response) {
19
            $('#' + domId).html(response);
3499 mandeep.dh 20
            loadOrderInfo("bottom-infopane", orderId);
3228 mandeep.dh 21
            orderTable = $('#user-orders').dataTable({
22
                "aaSorting" : [ [ 1, 'desc' ] ],
4241 anupam.sin 23
              "bAutoWidth": false,
24
              "aoColumns" : [{ "sWidth": "16%" },//order id
25
                             { "sWidth": "30%" },//item desc
26
                             { "sWidth": "16%" },//created
27
                             { "sWidth": "8%" },//amount
28
                             { "sWidth": "17%" },//status
29
                             { "sWidth": "9%" }],//mobile no.
3996 mandeep.dh 30
                "fnDrawCallback": function() { truncateText(125); },
4605 anupam.sin 31
                "iDisplayLength" : 10,
3339 mandeep.dh 32
                "sDom" : 'T<"clear">lfrtip',
33
                "oTableTools" : {
34
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
35
                },
3228 mandeep.dh 36
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
37
            });
38
        }
39
    });
2674 vikas 40
}
41
 
3228 mandeep.dh 42
function loadCartPane(domId, userId, cartId) {
43
    $.ajax({
44
        type : "GET",
45
        url : "/crm/user-cart?userId=" + userId + "&cartId=" + cartId,
46
        success : function(response) {
47
            $('#' + domId).html(response);
48
            cartTable = $('#user-cart').dataTable({
49
                "aaSorting" : [ [ 1, 'desc' ] ],
4241 anupam.sin 50
              "bAutoWidth": false,
51
              "aoColumns" : [{ "sWidth": "32%" },//name
52
                             { "sWidth": "9%" },//quantity
53
                             { "sWidth": "16%" },//actual price
54
                             { "sWidth": "16%" },//discounted price
55
                             { "sWidth": "9%" },//estimate
56
                             { "sWidth": "18%" }],//created on
3228 mandeep.dh 57
                "iDisplayLength" : 10,
3339 mandeep.dh 58
                "sDom" : 'T<"clear">lfrtip',
59
                "oTableTools" : {
60
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
61
                },
3228 mandeep.dh 62
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
63
            });
64
        }
65
    });
2714 vikas 66
}
67
 
3499 mandeep.dh 68
function loadOrderInfo(domId, orderId) {
3228 mandeep.dh 69
    $.ajax({
70
        type : "GET",
3499 mandeep.dh 71
        url : "/crm/user-order-info?orderId=" + orderId,
3228 mandeep.dh 72
        success : function(response) {
73
            $('#' + domId).html(response);
3220 mandeep.dh 74
 
3228 mandeep.dh 75
            var trId = 'order-row-' + orderId;
76
            if (orderTable != null) {
77
                for ( var index in orderTable.fnGetNodes()) {
78
                    var item = orderTable.fnGetNodes()[index];
79
                    if ($(item).attr('id') == trId) {
80
                        orderTable.fnDisplayRow(item);
81
                        break;
82
                    }
83
                }
84
            }
3220 mandeep.dh 85
 
3228 mandeep.dh 86
            $('#user-orders tr').removeClass('selected');
87
            $('#order-row-' + orderId).addClass('selected');
88
        }
89
    });
2714 vikas 90
}
91
 
3228 mandeep.dh 92
function loadLineInfo(domId, userId, itemId) {
93
    $.ajax({
94
        type : "GET",
95
        url : "/crm/user-line-info?userId=" + userId + "&itemId=" + itemId,
96
        success : function(response) {
97
            $('#' + domId).html(response);
98
            $('#user-cart tr').removeClass('selected');
99
            $('#cart-row-' + itemId).addClass('selected');
100
        }
101
    });
2830 vikas 102
}
103
 
3228 mandeep.dh 104
function loadTicketInfo(domId, ticketId, ticketTable, activityId) {
105
    $.ajax({
106
        type : "GET",
3405 mandeep.dh 107
        url : "/crm/tickets/" + ticketId + "/edit",
3228 mandeep.dh 108
        success : function(response) {
109
            $('#' + domId).html(response);
3206 mandeep.dh 110
 
3228 mandeep.dh 111
            var trId = 'ticket-row-' + ticketId;
112
            if (ticketTable != null) {
113
                for ( var index in ticketTable.fnGetNodes()) {
114
                    var item = ticketTable.fnGetNodes()[index];
115
                    if ($(item).attr('id') == trId) {
116
                        ticketTable.fnDisplayRow(item);
117
                        break;
118
                    }
119
                }
120
            }
3206 mandeep.dh 121
 
3228 mandeep.dh 122
            $('#tickets tr').removeClass('selected');
123
            $('#' + trId).addClass('selected');
124
 
125
            // For tickets accessed from activity page
126
            if (activityId != null) {
3339 mandeep.dh 127
                $('#activity tr').removeClass('selected');
3228 mandeep.dh 128
                $('#activity-row-' + activityId).addClass('selected');
129
            }
3546 mandeep.dh 130
 
131
            $('#order-table').dataTable({
132
                "aaSorting" : [ [ 2, 'desc' ] ],
4241 anupam.sin 133
//            "bAutoWidth": false,
134
//            "aoColumns" : [{ "sWidth": "5%" },
135
//                           { "sWidth": "20%" },
136
//                           { "sWidth": "20%" },
137
//                           { "sWidth": "12.5%" },
138
//                           { "sWidth": "12.5%" },
139
//                           { "sWidth": "10%" },
140
//                           { "sWidth": "10%" },
141
//                           { "sWidth": "10%" }],
4605 anupam.sin 142
                "iDisplayLength" : 10,
3546 mandeep.dh 143
                "fnDrawCallback": function() {truncateText(100);},
144
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
145
            });
3228 mandeep.dh 146
        }
147
    });
3090 mandeep.dh 148
}
149
 
3405 mandeep.dh 150
function createTicketDataTable(domId) {
3499 mandeep.dh 151
    var ticketsTable = $('#' + domId).dataTable({
4142 mandeep.dh 152
         "aaSorting" : [ [ 3, 'asc' ] ],
4241 anupam.sin 153
         "bAutoWidth": false,
154
         "aoColumns" : [{ "sWidth": "9%" },//ticket id
155
                        { "sWidth": "16%" },//customer id or Description when orderId is set
156
                        { "sWidth": "21%" },//category id
157
                        { "sWidth": "13%" },//date created
158
                        { "sWidth": "13%" },//date closed
159
                        { "sWidth": "12%" },//assignee
160
                        { "sWidth": "8%" },//status
161
                        { "sWidth": "8%" }],//priority
3546 mandeep.dh 162
        "fnDrawCallback": function() {truncateText(85);},
4605 anupam.sin 163
        "iDisplayLength" : 10,
3339 mandeep.dh 164
        "sDom" : 'T<"clear">lfrtip',
165
        "oTableTools" : {
166
            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
167
        },
168
        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
169
    });
3499 mandeep.dh 170
 
171
    return ticketsTable;
3339 mandeep.dh 172
}
173
 
4241 anupam.sin 174
function loadActivityDescription(domId, aActivityId) {
175
	$('#' + domId).html("<h4>Activity Description :</h4><pre>" + $(aActivityId).parent().siblings('td[id="activity-description"]').attr('title') + '</pre>');
176
    $('#activity-table tr').removeClass('selected');
177
    $(aActivityId).parent().parent().addClass('selected');
178
}
179
 
3422 mandeep.dh 180
function loadActivityInfo(domId, activityId) {
3228 mandeep.dh 181
    $.ajax({
182
        type : "GET",
3422 mandeep.dh 183
        url : "/crm/activity-info?activityId=" + activityId,
3228 mandeep.dh 184
        success : function(response) {
185
            $('#' + domId).html(response);
3339 mandeep.dh 186
            $('#activity tr').removeClass('selected');
3228 mandeep.dh 187
            $('#activity-row-' + activityId).addClass('selected');
3390 mandeep.dh 188
            $('#activity').css('table-layout', 'fixed');
3228 mandeep.dh 189
        }
190
    });
3090 mandeep.dh 191
}
192
 
3405 mandeep.dh 193
function createActivityDataTable(domId) {
3499 mandeep.dh 194
    var activityTable = $('#' + domId).dataTable({
3339 mandeep.dh 195
        "aaSorting" : [ [ 4, 'desc' ] ],
4241 anupam.sin 196
     "bAutoWidth": false,
197
      "aoColumns" : [{ "sWidth": "10%" },//id
198
                     { "sWidth": "22%" },//activity type
199
                     { "sWidth": "15%" },//description
200
                     { "sWidth": "12%" },//timestamp
201
                     { "sWidth": "12%" },//creator
202
                     { "sWidth": "12%" },//customer id
203
                     { "sWidth": "9%" },//ticket id
204
                     { "sWidth": "8%" }],//category
4605 anupam.sin 205
        "iDisplayLength" : 10,
3339 mandeep.dh 206
        "sDom" : 'T<"clear">lfrtip',
3546 mandeep.dh 207
        "fnDrawCallback": function() {truncateText(95);},
3339 mandeep.dh 208
        "oTableTools" : {
209
            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
210
        },
211
        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
212
    });
3499 mandeep.dh 213
 
214
    return activityTable;
3339 mandeep.dh 215
}
216
 
4793 amar.kumar 217
function loadAgentsInfo(domId) {
218
	$.ajax({
219
		type    : "GET",
220
		url	    : "/crm/agent",
221
		success : function(response) {
222
			$('#' + domId).html(response);
223
 
224
			var agentTable = $('#agents').dataTable({
225
                "aaSorting" : [ [ 1, 'asc' ] ],
226
                "bAutoWidth": false,
227
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
228
                               { "sWidth": "35%" },//Agent Name
229
                               { "sWidth": "40%" },//Email ID
230
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
231
                "iDisplayLength" : 10,
232
                "sDom" : 'T<"clear">lfrtip',
233
                "oTableTools" : {
234
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
235
                },
236
            });
237
		}
238
	});
239
}
240
 
3405 mandeep.dh 241
function loadTicketCreationForm(domId, params) {
3228 mandeep.dh 242
    $.ajax({
243
        type : "GET",
3339 mandeep.dh 244
        url : "/crm/tickets/new",
3405 mandeep.dh 245
        data : params,
3339 mandeep.dh 246
        success : function(response) {
247
            $('#' + domId).html(response);
248
        }
249
    });
250
}
251
 
3405 mandeep.dh 252
function loadActivityCreationForm(domId, params) {
3339 mandeep.dh 253
    $.ajax({
254
        type : "GET",
255
        url : "/crm/activity/new",
3405 mandeep.dh 256
        data : params,
3339 mandeep.dh 257
        success : function(response) {
258
            $('#' + domId).html(response);
259
        }
260
    });
261
}
262
 
3090 mandeep.dh 263
function updateTicket(domId, ticketId, params) {
3228 mandeep.dh 264
    $.ajax({
4782 mandeep.dh 265
        type : "POST",
266
        url : "/crm/tickets!update?id=" + ticketId,
267
        data : params,
3228 mandeep.dh 268
        success : function(response) {
3339 mandeep.dh 269
            var ticketTable = $('table[id$="tickets"]');
270
            if (ticketTable.length == 1) {
271
                var rowIndex = ticketTable.dataTable().fnGetPosition($('tr#ticket-row-' + ticketId)[0]);
272
                var responseObj = jQuery(response);
3546 mandeep.dh 273
                var actionMessages = responseObj.find('#action-messages').html();
3339 mandeep.dh 274
                responseObj.find('#ticket-row-' + ticketId).children().each(
275
                        function(i, item) {
276
                            var th = responseObj.find('th').eq(i);
277
                            if (th.text() == "Ticket Id") {
278
                                return;
279
                            }
280
 
281
                            var thOld = ticketTable.find('th').filter(
282
                                    function(index) {
283
                                        if ($(this).text() == th.text()) {
284
                                            return true;
285
                                        }
286
 
287
                                        return false;
288
                                    });
289
 
4249 anupam.sin 290
                            if ($(thOld).length != 0) {
3339 mandeep.dh 291
                                ticketTable.dataTable().fnUpdate($(item).text(), rowIndex, $(thOld).index(), true, false);
292
                            }
293
                        });
294
 
3546 mandeep.dh 295
                loadTicketInfo("bottom-infopane", ticketId, ticketTable.dataTable(), null);
3339 mandeep.dh 296
                ticketTable.css('table-layout', 'fixed');
3546 mandeep.dh 297
 
298
                var alertString = jQuery.trim(actionMessages);
299
                if (alertString != '') {
300
                    alert(alertString);
301
                }
3339 mandeep.dh 302
            }
303
            else {
304
                loadTicketInfo("bottom-infopane", ticketId, null, null);
305
            }
306
 
3499 mandeep.dh 307
            truncateText(85);
3339 mandeep.dh 308
        }
309
    });
310
}
311
 
3090 mandeep.dh 312
function createTicket(domId, params) {
3228 mandeep.dh 313
    $.ajax({
314
        type : "POST",
3339 mandeep.dh 315
        url : "/crm/tickets",
3228 mandeep.dh 316
        data : params,
317
        success : function(response) {
318
            $('#' + domId).html(response);
3405 mandeep.dh 319
            var ticketTable = createTicketDataTable('tickets');
3228 mandeep.dh 320
        }
321
    });
3090 mandeep.dh 322
}
323
 
4793 amar.kumar 324
function createAgent(params, managerId){
325
	$.ajax({
326
		type : "POST",
327
		url : "/crm/agent!createAgent?managerId="+managerId,
328
		data : params,
329
		success : function(response) {
330
			alert("Agent created with the specified information");
331
			$.colorbox.close();
332
			$('#infopane').html(response);
333
			var agentTable = $('#agents').dataTable({
334
                "aaSorting" : [ [ 1, 'asc' ] ],
335
                "bAutoWidth": false,
336
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
337
                               { "sWidth": "35%" },//Agent Name
338
                               { "sWidth": "40%" },//Email ID
339
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
340
                "iDisplayLength" : 10,
341
                "sDom" : 'T<"clear">lfrtip',
342
                "oTableTools" : {
343
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
344
                },
345
            });
346
		}
347
	});
348
}
349
 
5168 amar.kumar 350
function changeAgentRole(params){
351
	$.ajax({
352
		type : "POST",
353
		url : "/crm/agent!changeAgentRole",
354
		data : params,
355
		success : function(response) {
356
			alert("Agent role changed");
357
			$.colorbox.close();
358
			$('#infopane').html(response);
359
			var agentTable = $('#agents').dataTable({
360
                "aaSorting" : [ [ 1, 'asc' ] ],
361
                "bAutoWidth": false,
362
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
363
                               { "sWidth": "35%" },//Agent Name
364
                               { "sWidth": "40%" },//Email ID
365
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
366
                "iDisplayLength" : 10,
367
                "sDom" : 'T<"clear">lfrtip',
368
                "oTableTools" : {
369
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
370
                },
371
            });
372
		}
373
	});
374
}
375
 
3090 mandeep.dh 376
function createActivity(domId, params) {
3228 mandeep.dh 377
    $.ajax({
378
        type : "POST",
3339 mandeep.dh 379
        url : "/crm/activity",
3228 mandeep.dh 380
        data : params,
381
        success : function(response) {
382
            $('#' + domId).html(response);
3405 mandeep.dh 383
            var activityTable = createActivityDataTable('activity');
3228 mandeep.dh 384
        }
385
    });
3106 mandeep.dh 386
}
387
 
388
function goToHomePage() {
3228 mandeep.dh 389
    document.location.href = "/crm";
3106 mandeep.dh 390
}
391
 
3422 mandeep.dh 392
function loadTickets(domId, getURL, ticketId) {
3228 mandeep.dh 393
    $.ajax({
394
        type : "GET",
3234 mandeep.dh 395
        url : getURL,
3228 mandeep.dh 396
        success : function(response) {
397
            $('#' + domId).html(response);
3405 mandeep.dh 398
            var ticketTable = createTicketDataTable('tickets');
3422 mandeep.dh 399
            if (ticketId != null) {
400
                loadTicketInfo("bottom-infopane", ticketId, ticketTable.dataTable(), null);
401
                ticketTable.css('table-layout', 'fixed');
402
            }
3228 mandeep.dh 403
        }
404
    });
3106 mandeep.dh 405
}
3137 mandeep.dh 406
 
3422 mandeep.dh 407
function processActivityTypeChange(activityType) {
3269 mandeep.dh 408
    if (activityType == "SEND_EMAIL_TO_CUSTOMER") {
3228 mandeep.dh 409
        $.colorbox({
410
            inline : true,
3519 mandeep.dh 411
            width : "775px",
412
            height : "445px",
3228 mandeep.dh 413
            href : "div#mail-div",
414
            onClosed : function() {
3519 mandeep.dh 415
				CKEDITOR.instances['mail-body'].destroy(false);
3228 mandeep.dh 416
                $("div#mail-div").hide();
417
                $('select#activity-type').val('OTHER');
418
            }
419
        });
3206 mandeep.dh 420
 
3228 mandeep.dh 421
        $("div#mail-div").show();
3701 mandeep.dh 422
        $('#mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
3228 mandeep.dh 423
    }
4020 mandeep.dh 424
    else if (activityType == "ESCALATE_TICKET") {
425
        $.colorbox({
426
            inline : true,
427
            width : "675px",
4027 mandeep.dh 428
            height : "560px",
4020 mandeep.dh 429
            href : "div#escalation-div",
430
            onClosed : function() {
431
                CKEDITOR.instances['escalation-mail-body'].destroy(false);
432
                $("div#escalation-div").hide();
433
                $('select#activity-type').val('OTHER');
434
            }
435
        });
436
 
437
        $("div#escalation-div").show();
438
        $('#escalation-mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
439
    }
3206 mandeep.dh 440
}
441
 
442
function processInputFormSubmit() {
3228 mandeep.dh 443
    $.ajax({
444
        type : "POST",
445
        url : "/crm/",
446
        success : function(response) {
447
            $.html(response);
3405 mandeep.dh 448
            var ticketTable = createTicketDataTable('tickets');
3228 mandeep.dh 449
        }
450
    });
3339 mandeep.dh 451
}
452
 
453
function listActivities(domId, params) {
454
    $.ajax({
455
        type : "GET",
456
        url : "/crm/activity",
457
        data : params,
458
        success : function(response) {
459
            $('#' + domId).html(response);
3405 mandeep.dh 460
            var activityTable = createActivityDataTable('activity');
3339 mandeep.dh 461
        }
462
    });
463
}
464
 
465
function truncateText(widthSize) {
4241 anupam.sin 466
    $(".truncated-text").each(function() {
467
    	$(this).truncate({
468
            width : $(this).attr('truncatedTextWidth'),
469
            addtitle : true
470
        });
471
	})
3339 mandeep.dh 472
}
3390 mandeep.dh 473
 
474
function markAsRead(activityId) {
475
    $.ajax({
476
        type : "POST",
477
        url : "/crm/activity!markAsRead?activityId=" + activityId,
478
        success: function(response) {
479
            listActivities('infopane', "creatorId=1");
480
        }
481
    });
482
}
3397 mandeep.dh 483
 
484
function loadAdvancedSearchBox() {
485
    $.colorbox({
486
        inline : true,
487
        width : "535px",
488
        height : "465px",
489
        href : "form#search",
490
        onClosed : function() {
491
            $("form#search").hide();
492
        }
493
    });
494
 
495
    $("form#search").show();
496
}
497
 
498
function processSearchEntityChange(searchEntity) {
499
    if (searchEntity == "Tickets") {
500
        $("#assignee").show();
501
        $("#creator").hide();
4142 mandeep.dh 502
        $("tr#activityTypes").hide();
3397 mandeep.dh 503
    }
504
    else if (searchEntity == "Activities") {
505
        $("#assignee").hide();
506
        $("#creator").show();
4142 mandeep.dh 507
        $("tr#activityTypes").show();
3397 mandeep.dh 508
    }
509
}
3499 mandeep.dh 510
 
511
function increaseTrustLevel(domId, userId, trustLevelDelta) {
512
    $.ajax({
513
        type : "PUT",
514
        url : "/crm/user-info/" + userId + "?trustLevelDelta=" + trustLevelDelta,
515
        success : function(response) {
516
            $('#' + domId).html(response);
517
        }
518
    });
519
}
520
 
4241 anupam.sin 521
function displayCancelOrderPopUp() {
522
    	$.colorbox({
523
            inline : true,
524
            width : "650px",
4314 anupam.sin 525
            height : "550px",
4689 anupam.sin 526
            href : "div#cancel-div",
4241 anupam.sin 527
            onClosed : function() {
4689 anupam.sin 528
                CKEDITOR.instances['cancel-body'].destroy(false);
529
                $("div#cancel-div").hide();
4241 anupam.sin 530
            }
531
        });
532
 
4689 anupam.sin 533
        $("div#cancel-div").show();
534
        $('#cancel-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
4241 anupam.sin 535
}
536
 
537
function cancelOrder(domId, ticketId, orderId, orderStatus, formData) {
4704 anupam.sin 538
	if ($('#cancellationInitiator').val()) {
4689 anupam.sin 539
		var cancellationInitiator = $('#cancellationInitiator').val();
540
		var uri = "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId
541
						+ "&cancellationInitiator=" + cancellationInitiator + "&" + formData;
542
		var cancellationResult = function() {
543
			document.location.href = "/crm?email=&orderId=" + orderId;
544
		}
545
	} else {
546
		var uri = "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
547
						+ "&orderStatus=" + orderStatus + "&" + formData;
548
		var cancellationResult = function(response) {
549
            $('#' + domId).html(response);
550
        }
551
	}
4241 anupam.sin 552
    $.ajax({
553
        type : "POST",
4689 anupam.sin 554
        url : uri,
555
        success : cancellationResult
4241 anupam.sin 556
    });
4681 amar.kumar 557
 
558
    if(formData.indexOf("LOWER_PRICE_AVAILABLE_ELSEWHERE")!=-1){
559
    	var desc = formData.split("&");
560
    	var description = "Order cancelled because of Lower Price Available elsewhere";
561
    	$.ajax({
562
    		type : "POST",
563
    		url : "/crm/tickets?orderId="+orderId+"&priority=MEDIUM&category=PRODUCT_PROCUREMENT"
564
    				+ "&assigneeEmailId=chaitnaya.vats@shop2020.in&description="+description+"&"+desc[1],
565
    		success : function(response){
566
    			alert("Ticket created for Lower Price Available elsewhere");
567
    		}
568
    	});
569
 
570
    }
4241 anupam.sin 571
}
4065 mandeep.dh 572
 
4241 anupam.sin 573
function updateOrderStatus(domId, ticketId, orderId, orderStatus) {
3499 mandeep.dh 574
    $.ajax({
3546 mandeep.dh 575
        type : "POST",
4241 anupam.sin 576
        url : "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
577
        					+ "&orderStatus=" + orderStatus,
3499 mandeep.dh 578
        success : function(response) {
3546 mandeep.dh 579
            $('#' + domId).html(response);
3499 mandeep.dh 580
        }
581
    });
3711 mandeep.dh 582
}
583
 
584
function loadUnreadActivities(domId) {
585
    $.ajax({
586
        type : "GET",
587
        url : "/crm/activity!getUnreadActivities",
588
        success : function(response) {
589
            $('#' + domId).html(response);
590
            var activityTable = createActivityDataTable('activity');
591
        }
592
    });
593
}
4065 mandeep.dh 594
 
595
function refreshSidebar() {
596
    $.ajax({
4142 mandeep.dh 597
        type : "PUT",
598
        url : "/crm",
599
        success : function(response) {
600
            $('#sidebar').html($(response).find('#sidebar').html());
601
        }
602
    });
603
}
604
 
605
function changeAddress(urlParams) {
606
    $.ajax({
4065 mandeep.dh 607
        type : "GET",
608
        url : "/crm",
609
        success : function(response) {
610
            $('#sidebar').html($(response).find('#sidebar').html());
611
        }
612
    });
4267 anupam.sin 613
}
614
 
4681 amar.kumar 615
function showHidecancelReasonDiv(cancelReason){
4793 amar.kumar 616
	var reasonsToShowDiv = ['LOWER_PRICE_AVAILABLE_ELSEWHERE','OTHER','OUT_OF_STOCK','COLOR_OUT_OF_STOCK'];
617
	if(($.inArray(cancelReason, reasonsToShowDiv))!=-1){
4681 amar.kumar 618
		$('#cancelReasonBox').show();
619
	} else {
620
		$('#cancelReasonBox').hide();
621
	}
622
}
623
 
4438 anupam.sin 624
function blockPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 625
	$.ajax({
626
		type : "GET",
4451 anupam.sin 627
		url : "/crm/tickets!blockPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 628
		success : function(response) {
629
            $('#bottom-infopane').html(response);
630
        }
631
	});
632
}
633
 
4438 anupam.sin 634
function allowPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 635
	$.ajax({
636
		type : "GET",
4451 anupam.sin 637
		url : "/crm/tickets!allowPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 638
		success : function(response) {
639
            $('#bottom-infopane').html(response);
640
        }
641
	});
4490 anupam.sin 642
}
643
 
644
function denyDOA(orderId, ticketId) {
645
	$.ajax({
646
		type : "GET",
647
		url : "/crm/tickets!denyDOA?orderId=" + orderId + "&id=" + ticketId,
648
		success : function(response) {
649
            $('#bottom-infopane').html(response);
650
        }
651
	});
652
}
653
 
654
 
655
function authorizeDOA(orderId, ticketId) {
656
	$.ajax({
657
		type : "GET",
658
		url : "/crm/tickets!authorizeDOA?orderId=" + orderId + "&id=" + ticketId,
659
		success : function(response) {
660
            $('#bottom-infopane').html(response);
661
        }
662
	});
663
}
664
 
665
function denyReturn(orderId, ticketId) {
666
	$.ajax({
667
		type : "GET",
668
		url : "/crm/tickets!denyReturn?orderId=" + orderId + "&id=" + ticketId,
669
		success : function(response) {
670
            $('#bottom-infopane').html(response);
671
        }
672
	});
673
}
674
 
675
 
676
function authorizeReturn(orderId, ticketId) {
677
	$.ajax({
678
		type : "GET",
679
		url : "/crm/tickets!authorizeReturn?orderId=" + orderId + "&id=" + ticketId,
680
		success : function(response) {
681
            $('#bottom-infopane').html(response);
682
        }
683
	});
4689 anupam.sin 684
}
685
 
686
function markOrderForCancellation(orderId, formData) {
687
	console.log(typeof(orderId), typeof(formData), orderId, formData);
688
 
689
	$.ajax({
690
		type : "GET",
691
		url : "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId + "&cancellationInitiator=" + formData,
692
		success : function(response) {
693
			document.location.href = "/crm?email=&orderId=" + orderId;
694
        }
695
	});
4793 amar.kumar 696
}
697
 
698
function loadAgentCreationForm() {
699
	$.colorbox({
700
        inline : true,
701
        width : "550px",
702
        height : "400px",
703
        href : "div#create-agent-div",
704
        onClosed : function() {
705
            $("div#create-agent-div").hide();
706
        }
707
    });
708
 
709
    $("div#create-agent-div").show();
710
 
711
}
712
 
713
function deactivateAgentPopup() {
714
	$.colorbox({
715
        inline : true,
716
        width : "400px",
717
        height : "150px",
718
        href : "div#deactivate-agent-div",
719
        onClosed : function() {
720
            $("div#deactivate-agent-div").hide();
721
        }
722
    });
723
 
724
    $("div#deactivate-agent-div").show();
725
 
726
}
727
 
728
function changeAgentPasswordPopup(){
729
	$.colorbox({
730
        inline : true,
731
        width  : "350px",
732
        height : "350px",
733
        href   : "div#change-password-div",
734
        onClosed : function() {
735
            $("div#change-password-div").hide();
736
        }
737
    });
738
 
739
    $("div#change-password-div").show();
740
}
741
 
5168 amar.kumar 742
function changeAgentRolePopup(){
743
	$.colorbox({
744
        inline : true,
745
        width  : "375px",
746
        height : "350px",
747
        href   : "div#change-agent-role-div",
748
        onClosed : function() {
749
            $("div#change-agent-role-div").hide();
750
        }
751
    });
4793 amar.kumar 752
 
5168 amar.kumar 753
    $("div#change-agent-role-div").show();
754
}
755
 
4793 amar.kumar 756
function updateAgentPassword(){
757
	if(($('#change-password1').val().trim())==($('#change-password2').val().trim())){
758
		$.ajax({
759
			type : "POST",
760
			url : "/crm/agent!changePassword?emailId=" + $('#agentEmail').val() + "&newPassword=" + $('#change-password1').val().trim(),
761
			success : function(response) {
762
				alert("Password updated successfully");
763
				$.colorbox.close();
764
			}
765
		});
766
	}
767
	else { 
768
		alert("Passwords not matching");
769
		return false;
770
	}
771
}
772
 
773
function validateAgentCreationForm(){
774
	var formError = false;
775
	if($('#new-agent-name').val().length == 0) {
776
		$('#agent-name-error').html("Please enter the name");
777
		$('#new-agent-name').addClass('agent-form-error');
778
		formError = true;
779
	}
780
	if(($('#new-agent-id').val().length == 0)) {
781
		$('#agent-email-error').html("Please enter the Email-ID");
782
		$('#new-agent-id').addClass('agent-form-error');
783
		formError = true;
784
	}
785
	if($('#create-password1').val().length == 0) {
786
		$('#agent-password1-error').html("Please enter password");
787
		$('#create-password1').addClass('agent-form-error');
788
		formError = true;
789
	} else if($('#create-password2').val().length == 0){
790
		$('#agent-password2-error').html("Please re enter password");
791
		$('#create-password2').addClass('agent-form-error');
792
		formError = true;
793
	} else if($('#create-password1').val()!=$('#create-password2').val()) {
794
		$('#agent-password1-error').html("Please make sure you entered same passwords");
795
		$('#create-password1').addClass('agent-form-error');
796
		$('#create-password2').addClass('agent-form-error');
797
		formError = true;
798
	}
799
 
800
	if(formError){
801
		return false;
802
	}
803
	return true;
804
}
805
 
806
function clearAgentCreationForm() {
807
		$('#agent-name-error').html("");
808
		$('#new-agent-name').removeClass('agent-form-error');
809
		$('#agent-email-error').html("");
810
		$('#new-agent-id').removeClass('agent-form-error');
811
		$('#agent-password1-error').html("");
812
		$('#create-password1').removeClass('agent-form-error');
813
		$('#agent-password2-error').html("");
814
		$('#create-password2').removeClass('agent-form-error');
815
		$('#agent-password1-error').html("");
816
		$('#create-password1').removeClass('agent-form-error');
817
		$('#create-password2').removeClass('agent-form-error');
818
}
819
 
820
function deactivateAgent(emailId, id) {
821
	$.ajax({
822
		type : "POST",
823
		url : "/crm/agent!deActivateAgent?emailId=" + emailId+ "&id=" + id,
824
		success : function(response) {   
825
			alert("Agent : " + "deactivated successfully");
826
			$.colorbox.close();
827
			$('#infopane').html(response);
828
 
829
			var agentTable = $('#agents').dataTable({
830
                "aaSorting" : [ [ 1, 'asc' ] ],
831
                "bAutoWidth": false,
832
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
833
                               { "sWidth": "35%" },//Agent Name
834
                               { "sWidth": "40%" },//Email ID
835
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
836
                "iDisplayLength" : 10,
837
                "sDom" : 'T<"clear">lfrtip',
838
                "oTableTools" : {
839
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
840
                },
841
            });
842
		}
843
	});
4241 anupam.sin 844
}