Subversion Repositories SmartDukaan

Rev

Rev 4782 | Rev 5168 | 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
 
3090 mandeep.dh 350
function createActivity(domId, params) {
3228 mandeep.dh 351
    $.ajax({
352
        type : "POST",
3339 mandeep.dh 353
        url : "/crm/activity",
3228 mandeep.dh 354
        data : params,
355
        success : function(response) {
356
            $('#' + domId).html(response);
3405 mandeep.dh 357
            var activityTable = createActivityDataTable('activity');
3228 mandeep.dh 358
        }
359
    });
3106 mandeep.dh 360
}
361
 
362
function goToHomePage() {
3228 mandeep.dh 363
    document.location.href = "/crm";
3106 mandeep.dh 364
}
365
 
3422 mandeep.dh 366
function loadTickets(domId, getURL, ticketId) {
3228 mandeep.dh 367
    $.ajax({
368
        type : "GET",
3234 mandeep.dh 369
        url : getURL,
3228 mandeep.dh 370
        success : function(response) {
371
            $('#' + domId).html(response);
3405 mandeep.dh 372
            var ticketTable = createTicketDataTable('tickets');
3422 mandeep.dh 373
            if (ticketId != null) {
374
                loadTicketInfo("bottom-infopane", ticketId, ticketTable.dataTable(), null);
375
                ticketTable.css('table-layout', 'fixed');
376
            }
3228 mandeep.dh 377
        }
378
    });
3106 mandeep.dh 379
}
3137 mandeep.dh 380
 
3422 mandeep.dh 381
function processActivityTypeChange(activityType) {
3269 mandeep.dh 382
    if (activityType == "SEND_EMAIL_TO_CUSTOMER") {
3228 mandeep.dh 383
        $.colorbox({
384
            inline : true,
3519 mandeep.dh 385
            width : "775px",
386
            height : "445px",
3228 mandeep.dh 387
            href : "div#mail-div",
388
            onClosed : function() {
3519 mandeep.dh 389
				CKEDITOR.instances['mail-body'].destroy(false);
3228 mandeep.dh 390
                $("div#mail-div").hide();
391
                $('select#activity-type').val('OTHER');
392
            }
393
        });
3206 mandeep.dh 394
 
3228 mandeep.dh 395
        $("div#mail-div").show();
3701 mandeep.dh 396
        $('#mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
3228 mandeep.dh 397
    }
4020 mandeep.dh 398
    else if (activityType == "ESCALATE_TICKET") {
399
        $.colorbox({
400
            inline : true,
401
            width : "675px",
4027 mandeep.dh 402
            height : "560px",
4020 mandeep.dh 403
            href : "div#escalation-div",
404
            onClosed : function() {
405
                CKEDITOR.instances['escalation-mail-body'].destroy(false);
406
                $("div#escalation-div").hide();
407
                $('select#activity-type').val('OTHER');
408
            }
409
        });
410
 
411
        $("div#escalation-div").show();
412
        $('#escalation-mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
413
    }
3206 mandeep.dh 414
}
415
 
416
function processInputFormSubmit() {
3228 mandeep.dh 417
    $.ajax({
418
        type : "POST",
419
        url : "/crm/",
420
        success : function(response) {
421
            $.html(response);
3405 mandeep.dh 422
            var ticketTable = createTicketDataTable('tickets');
3228 mandeep.dh 423
        }
424
    });
3339 mandeep.dh 425
}
426
 
427
function listActivities(domId, params) {
428
    $.ajax({
429
        type : "GET",
430
        url : "/crm/activity",
431
        data : params,
432
        success : function(response) {
433
            $('#' + domId).html(response);
3405 mandeep.dh 434
            var activityTable = createActivityDataTable('activity');
3339 mandeep.dh 435
        }
436
    });
437
}
438
 
439
function truncateText(widthSize) {
4241 anupam.sin 440
    $(".truncated-text").each(function() {
441
    	$(this).truncate({
442
            width : $(this).attr('truncatedTextWidth'),
443
            addtitle : true
444
        });
445
	})
3339 mandeep.dh 446
}
3390 mandeep.dh 447
 
448
function markAsRead(activityId) {
449
    $.ajax({
450
        type : "POST",
451
        url : "/crm/activity!markAsRead?activityId=" + activityId,
452
        success: function(response) {
453
            listActivities('infopane', "creatorId=1");
454
        }
455
    });
456
}
3397 mandeep.dh 457
 
458
function loadAdvancedSearchBox() {
459
    $.colorbox({
460
        inline : true,
461
        width : "535px",
462
        height : "465px",
463
        href : "form#search",
464
        onClosed : function() {
465
            $("form#search").hide();
466
        }
467
    });
468
 
469
    $("form#search").show();
470
}
471
 
472
function processSearchEntityChange(searchEntity) {
473
    if (searchEntity == "Tickets") {
474
        $("#assignee").show();
475
        $("#creator").hide();
4142 mandeep.dh 476
        $("tr#activityTypes").hide();
3397 mandeep.dh 477
    }
478
    else if (searchEntity == "Activities") {
479
        $("#assignee").hide();
480
        $("#creator").show();
4142 mandeep.dh 481
        $("tr#activityTypes").show();
3397 mandeep.dh 482
    }
483
}
3499 mandeep.dh 484
 
485
function increaseTrustLevel(domId, userId, trustLevelDelta) {
486
    $.ajax({
487
        type : "PUT",
488
        url : "/crm/user-info/" + userId + "?trustLevelDelta=" + trustLevelDelta,
489
        success : function(response) {
490
            $('#' + domId).html(response);
491
        }
492
    });
493
}
494
 
4241 anupam.sin 495
function displayCancelOrderPopUp() {
496
    	$.colorbox({
497
            inline : true,
498
            width : "650px",
4314 anupam.sin 499
            height : "550px",
4689 anupam.sin 500
            href : "div#cancel-div",
4241 anupam.sin 501
            onClosed : function() {
4689 anupam.sin 502
                CKEDITOR.instances['cancel-body'].destroy(false);
503
                $("div#cancel-div").hide();
4241 anupam.sin 504
            }
505
        });
506
 
4689 anupam.sin 507
        $("div#cancel-div").show();
508
        $('#cancel-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
4241 anupam.sin 509
}
510
 
511
function cancelOrder(domId, ticketId, orderId, orderStatus, formData) {
4704 anupam.sin 512
	if ($('#cancellationInitiator').val()) {
4689 anupam.sin 513
		var cancellationInitiator = $('#cancellationInitiator').val();
514
		var uri = "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId
515
						+ "&cancellationInitiator=" + cancellationInitiator + "&" + formData;
516
		var cancellationResult = function() {
517
			document.location.href = "/crm?email=&orderId=" + orderId;
518
		}
519
	} else {
520
		var uri = "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
521
						+ "&orderStatus=" + orderStatus + "&" + formData;
522
		var cancellationResult = function(response) {
523
            $('#' + domId).html(response);
524
        }
525
	}
4241 anupam.sin 526
    $.ajax({
527
        type : "POST",
4689 anupam.sin 528
        url : uri,
529
        success : cancellationResult
4241 anupam.sin 530
    });
4681 amar.kumar 531
 
532
    if(formData.indexOf("LOWER_PRICE_AVAILABLE_ELSEWHERE")!=-1){
533
    	var desc = formData.split("&");
534
    	var description = "Order cancelled because of Lower Price Available elsewhere";
535
    	$.ajax({
536
    		type : "POST",
537
    		url : "/crm/tickets?orderId="+orderId+"&priority=MEDIUM&category=PRODUCT_PROCUREMENT"
538
    				+ "&assigneeEmailId=chaitnaya.vats@shop2020.in&description="+description+"&"+desc[1],
539
    		success : function(response){
540
    			alert("Ticket created for Lower Price Available elsewhere");
541
    		}
542
    	});
543
 
544
    }
4241 anupam.sin 545
}
4065 mandeep.dh 546
 
4241 anupam.sin 547
function updateOrderStatus(domId, ticketId, orderId, orderStatus) {
3499 mandeep.dh 548
    $.ajax({
3546 mandeep.dh 549
        type : "POST",
4241 anupam.sin 550
        url : "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
551
        					+ "&orderStatus=" + orderStatus,
3499 mandeep.dh 552
        success : function(response) {
3546 mandeep.dh 553
            $('#' + domId).html(response);
3499 mandeep.dh 554
        }
555
    });
3711 mandeep.dh 556
}
557
 
558
function loadUnreadActivities(domId) {
559
    $.ajax({
560
        type : "GET",
561
        url : "/crm/activity!getUnreadActivities",
562
        success : function(response) {
563
            $('#' + domId).html(response);
564
            var activityTable = createActivityDataTable('activity');
565
        }
566
    });
567
}
4065 mandeep.dh 568
 
569
function refreshSidebar() {
570
    $.ajax({
4142 mandeep.dh 571
        type : "PUT",
572
        url : "/crm",
573
        success : function(response) {
574
            $('#sidebar').html($(response).find('#sidebar').html());
575
        }
576
    });
577
}
578
 
579
function changeAddress(urlParams) {
580
    $.ajax({
4065 mandeep.dh 581
        type : "GET",
582
        url : "/crm",
583
        success : function(response) {
584
            $('#sidebar').html($(response).find('#sidebar').html());
585
        }
586
    });
4267 anupam.sin 587
}
588
 
4681 amar.kumar 589
function showHidecancelReasonDiv(cancelReason){
4793 amar.kumar 590
	var reasonsToShowDiv = ['LOWER_PRICE_AVAILABLE_ELSEWHERE','OTHER','OUT_OF_STOCK','COLOR_OUT_OF_STOCK'];
591
	if(($.inArray(cancelReason, reasonsToShowDiv))!=-1){
4681 amar.kumar 592
		$('#cancelReasonBox').show();
593
	} else {
594
		$('#cancelReasonBox').hide();
595
	}
596
}
597
 
4438 anupam.sin 598
function blockPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 599
	$.ajax({
600
		type : "GET",
4451 anupam.sin 601
		url : "/crm/tickets!blockPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 602
		success : function(response) {
603
            $('#bottom-infopane').html(response);
604
        }
605
	});
606
}
607
 
4438 anupam.sin 608
function allowPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 609
	$.ajax({
610
		type : "GET",
4451 anupam.sin 611
		url : "/crm/tickets!allowPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 612
		success : function(response) {
613
            $('#bottom-infopane').html(response);
614
        }
615
	});
4490 anupam.sin 616
}
617
 
618
function denyDOA(orderId, ticketId) {
619
	$.ajax({
620
		type : "GET",
621
		url : "/crm/tickets!denyDOA?orderId=" + orderId + "&id=" + ticketId,
622
		success : function(response) {
623
            $('#bottom-infopane').html(response);
624
        }
625
	});
626
}
627
 
628
 
629
function authorizeDOA(orderId, ticketId) {
630
	$.ajax({
631
		type : "GET",
632
		url : "/crm/tickets!authorizeDOA?orderId=" + orderId + "&id=" + ticketId,
633
		success : function(response) {
634
            $('#bottom-infopane').html(response);
635
        }
636
	});
637
}
638
 
639
function denyReturn(orderId, ticketId) {
640
	$.ajax({
641
		type : "GET",
642
		url : "/crm/tickets!denyReturn?orderId=" + orderId + "&id=" + ticketId,
643
		success : function(response) {
644
            $('#bottom-infopane').html(response);
645
        }
646
	});
647
}
648
 
649
 
650
function authorizeReturn(orderId, ticketId) {
651
	$.ajax({
652
		type : "GET",
653
		url : "/crm/tickets!authorizeReturn?orderId=" + orderId + "&id=" + ticketId,
654
		success : function(response) {
655
            $('#bottom-infopane').html(response);
656
        }
657
	});
4689 anupam.sin 658
}
659
 
660
function markOrderForCancellation(orderId, formData) {
661
	console.log(typeof(orderId), typeof(formData), orderId, formData);
662
 
663
	$.ajax({
664
		type : "GET",
665
		url : "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId + "&cancellationInitiator=" + formData,
666
		success : function(response) {
667
			document.location.href = "/crm?email=&orderId=" + orderId;
668
        }
669
	});
4793 amar.kumar 670
}
671
 
672
function loadAgentCreationForm() {
673
	$.colorbox({
674
        inline : true,
675
        width : "550px",
676
        height : "400px",
677
        href : "div#create-agent-div",
678
        onClosed : function() {
679
            $("div#create-agent-div").hide();
680
        }
681
    });
682
 
683
    $("div#create-agent-div").show();
684
 
685
}
686
 
687
function deactivateAgentPopup() {
688
	$.colorbox({
689
        inline : true,
690
        width : "400px",
691
        height : "150px",
692
        href : "div#deactivate-agent-div",
693
        onClosed : function() {
694
            $("div#deactivate-agent-div").hide();
695
        }
696
    });
697
 
698
    $("div#deactivate-agent-div").show();
699
 
700
}
701
 
702
function changeAgentPasswordPopup(){
703
	$.colorbox({
704
        inline : true,
705
        width  : "350px",
706
        height : "350px",
707
        href   : "div#change-password-div",
708
        onClosed : function() {
709
            $("div#change-password-div").hide();
710
        }
711
    });
712
 
713
    $("div#change-password-div").show();
714
}
715
 
716
 
717
function updateAgentPassword(){
718
	if(($('#change-password1').val().trim())==($('#change-password2').val().trim())){
719
		$.ajax({
720
			type : "POST",
721
			url : "/crm/agent!changePassword?emailId=" + $('#agentEmail').val() + "&newPassword=" + $('#change-password1').val().trim(),
722
			success : function(response) {
723
				alert("Password updated successfully");
724
				$.colorbox.close();
725
			}
726
		});
727
	}
728
	else { 
729
		alert("Passwords not matching");
730
		return false;
731
	}
732
}
733
 
734
function validateAgentCreationForm(){
735
	var formError = false;
736
	if($('#new-agent-name').val().length == 0) {
737
		$('#agent-name-error').html("Please enter the name");
738
		$('#new-agent-name').addClass('agent-form-error');
739
		formError = true;
740
	}
741
	if(($('#new-agent-id').val().length == 0)) {
742
		$('#agent-email-error').html("Please enter the Email-ID");
743
		$('#new-agent-id').addClass('agent-form-error');
744
		formError = true;
745
	}
746
	if($('#create-password1').val().length == 0) {
747
		$('#agent-password1-error').html("Please enter password");
748
		$('#create-password1').addClass('agent-form-error');
749
		formError = true;
750
	} else if($('#create-password2').val().length == 0){
751
		$('#agent-password2-error').html("Please re enter password");
752
		$('#create-password2').addClass('agent-form-error');
753
		formError = true;
754
	} else if($('#create-password1').val()!=$('#create-password2').val()) {
755
		$('#agent-password1-error').html("Please make sure you entered same passwords");
756
		$('#create-password1').addClass('agent-form-error');
757
		$('#create-password2').addClass('agent-form-error');
758
		formError = true;
759
	}
760
 
761
	if(formError){
762
		return false;
763
	}
764
	return true;
765
}
766
 
767
function clearAgentCreationForm() {
768
		$('#agent-name-error').html("");
769
		$('#new-agent-name').removeClass('agent-form-error');
770
		$('#agent-email-error').html("");
771
		$('#new-agent-id').removeClass('agent-form-error');
772
		$('#agent-password1-error').html("");
773
		$('#create-password1').removeClass('agent-form-error');
774
		$('#agent-password2-error').html("");
775
		$('#create-password2').removeClass('agent-form-error');
776
		$('#agent-password1-error').html("");
777
		$('#create-password1').removeClass('agent-form-error');
778
		$('#create-password2').removeClass('agent-form-error');
779
}
780
 
781
function deactivateAgent(emailId, id) {
782
	$.ajax({
783
		type : "POST",
784
		url : "/crm/agent!deActivateAgent?emailId=" + emailId+ "&id=" + id,
785
		success : function(response) {   
786
			alert("Agent : " + "deactivated successfully");
787
			$.colorbox.close();
788
			$('#infopane').html(response);
789
 
790
			var agentTable = $('#agents').dataTable({
791
                "aaSorting" : [ [ 1, 'asc' ] ],
792
                "bAutoWidth": false,
793
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
794
                               { "sWidth": "35%" },//Agent Name
795
                               { "sWidth": "40%" },//Email ID
796
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
797
                "iDisplayLength" : 10,
798
                "sDom" : 'T<"clear">lfrtip',
799
                "oTableTools" : {
800
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
801
                },
802
            });
803
		}
804
	});
4241 anupam.sin 805
}