Subversion Repositories SmartDukaan

Rev

Rev 19072 | Rev 19088 | 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
}
18884 amit.gupta 13
aoColumns = {
14
	'return':
18887 amit.gupta 15
	[  { "sWidth": "8%" },
16
	   { "sWidth": "20%" },
18884 amit.gupta 17
	   { "sWidth": "5%" },
18
	   { "sWidth": "10%" },
19
	   { "sWidth": "15%" },
20
	   { "sWidth": "10%" },
18887 amit.gupta 21
	   { "sWidth": "12%" },
22
	   { "sWidth": "10%" },
23
	   { "sWidth": "10%" }],
18884 amit.gupta 24
 
25
 
26
	'delayed':
18887 amit.gupta 27
	[  { "sWidth": "8%" },
18884 amit.gupta 28
	   { "sWidth": "25%" },
29
	   { "sWidth": "5%" },
30
	   { "sWidth": "10%" },
31
	   { "sWidth": "15%" },
32
	   { "sWidth": "8%" },
33
	   { "sWidth": "10%" },
34
	   { "sWidth": "9%" },
18886 amit.gupta 35
	   { "sWidth": "12%" }],
18884 amit.gupta 36
	'codverification':
37
	[  { "sWidth": "8%" },
38
	   { "sWidth": "40%" },
39
	   { "sWidth": "5%" },
40
	   { "sWidth": "10%" },
41
	   { "sWidth": "17%" },
42
	   { "sWidth": "10%" },
18888 amit.gupta 43
	   { "sWidth": "10%" },
44
	   {"bVisible": false}
18886 amit.gupta 45
	],
18884 amit.gupta 46
	'storepickup':
47
	[  { "sWidth": "6%" },
48
	   { "sWidth": "25%" },
49
	   { "sWidth": "5%" },
50
	   { "sWidth": "8%" },
51
	   { "sWidth": "15%" },
52
	   { "sWidth": "8%" },
53
	   { "sWidth": "10%" },
54
	   { "sWidth": "12%" },
55
	   { "sWidth": "4%" },
18886 amit.gupta 56
	   { "sWidth": "7%" }]
18884 amit.gupta 57
};
3228 mandeep.dh 58
function loadOrderPane(domId, userId, orderId) {
59
    $.ajax({
60
        type : "GET",
61
        url : "/crm/user-orders?userId=" + userId,
62
        success : function(response) {
63
            $('#' + domId).html(response);
3499 mandeep.dh 64
            loadOrderInfo("bottom-infopane", orderId);
3228 mandeep.dh 65
            orderTable = $('#user-orders').dataTable({
66
                "aaSorting" : [ [ 1, 'desc' ] ],
4241 anupam.sin 67
              "bAutoWidth": false,
18583 amit.gupta 68
              "aoColumns" : [{ "sWidth": "8%" },//transaction id
69
                             { "sWidth": "7%" },//item desc
4241 anupam.sin 70
                             { "sWidth": "30%" },//item desc
18583 amit.gupta 71
                             { "sWidth": "4%" },//item desc
18308 amit.gupta 72
                             { "sWidth": "14%" },//created
4241 anupam.sin 73
                             { "sWidth": "8%" },//amount
74
                             { "sWidth": "17%" },//status
18308 amit.gupta 75
                             { "sWidth": "11%" }],//mobile no.
3996 mandeep.dh 76
                "fnDrawCallback": function() { truncateText(125); },
4605 anupam.sin 77
                "iDisplayLength" : 10,
3339 mandeep.dh 78
                "sDom" : 'T<"clear">lfrtip',
79
                "oTableTools" : {
80
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
81
                },
3228 mandeep.dh 82
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
83
            });
84
        }
85
    });
2674 vikas 86
}
87
 
6111 anupam.sin 88
function loadRechargeOrderPane(domId, userId, rechargeOrderId) {
89
    $.ajax({
90
        type : "GET",
91
        url : "/crm/recharge-orders?userId=" + userId,
92
        success : function(response) {
93
            $('#' + domId).html(response);
94
            loadRechargeOrderInfo("bottom-infopane", rechargeOrderId);
95
            orderTable = $('#recharge-orders').dataTable({
96
                "aaSorting" : [ [ 1, 'desc' ] ],
97
              "bAutoWidth": false,
98
              "aoColumns" : [{ "sWidth": "16%" },//recharge order id
99
                             { "sWidth": "30%" },//desc
100
                             { "sWidth": "16%" },//created
101
                             { "sWidth": "8%" },//amount
102
                             { "sWidth": "17%" },//status
6982 anupam.sin 103
                             { "sWidth": "13%" }],//mobile no.
104
                "fnDrawCallback": function() { truncateText(180); },
6111 anupam.sin 105
                "iDisplayLength" : 10,
106
                "sDom" : 'T<"clear">lfrtip',
107
                "oTableTools" : {
108
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
109
                },
110
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
111
            });
112
        }
113
    });
114
}
115
 
116
function loadRechargeOrderInfo(domId, rechargeOrderId) {
117
    $.ajax({
118
        type : "GET",
119
        url : "/crm/recharge-order-info?rechargeOrderId=" + rechargeOrderId,
120
        success : function(response) {
121
            $('#' + domId).html(response);
122
 
123
            var trId = 'order-row-' + rechargeOrderId;
124
            if (orderTable != null) {
125
                for ( var index in orderTable.fnGetNodes()) {
126
                    var item = orderTable.fnGetNodes()[index];
127
                    if ($(item).attr('id') == trId) {
128
                        orderTable.fnDisplayRow(item);
129
                        break;
130
                    }
131
                }
132
            }
133
 
134
            $('#recharge-orders tr').removeClass('selected');
6153 anupam.sin 135
            $('#order-row-' + rechargeOrderId).addClass('selected');
6111 anupam.sin 136
        }
137
    });
138
}
139
 
3228 mandeep.dh 140
function loadCartPane(domId, userId, cartId) {
141
    $.ajax({
142
        type : "GET",
143
        url : "/crm/user-cart?userId=" + userId + "&cartId=" + cartId,
144
        success : function(response) {
145
            $('#' + domId).html(response);
146
            cartTable = $('#user-cart').dataTable({
147
                "aaSorting" : [ [ 1, 'desc' ] ],
4241 anupam.sin 148
              "bAutoWidth": false,
149
              "aoColumns" : [{ "sWidth": "32%" },//name
150
                             { "sWidth": "9%" },//quantity
151
                             { "sWidth": "16%" },//actual price
152
                             { "sWidth": "16%" },//discounted price
153
                             { "sWidth": "9%" },//estimate
154
                             { "sWidth": "18%" }],//created on
3228 mandeep.dh 155
                "iDisplayLength" : 10,
3339 mandeep.dh 156
                "sDom" : 'T<"clear">lfrtip',
157
                "oTableTools" : {
158
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
159
                },
3228 mandeep.dh 160
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
161
            });
162
        }
163
    });
2714 vikas 164
}
165
 
3499 mandeep.dh 166
function loadOrderInfo(domId, orderId) {
3228 mandeep.dh 167
    $.ajax({
168
        type : "GET",
3499 mandeep.dh 169
        url : "/crm/user-order-info?orderId=" + orderId,
3228 mandeep.dh 170
        success : function(response) {
171
            $('#' + domId).html(response);
3220 mandeep.dh 172
 
3228 mandeep.dh 173
            var trId = 'order-row-' + orderId;
174
            if (orderTable != null) {
175
                for ( var index in orderTable.fnGetNodes()) {
176
                    var item = orderTable.fnGetNodes()[index];
177
                    if ($(item).attr('id') == trId) {
178
                        orderTable.fnDisplayRow(item);
179
                        break;
180
                    }
181
                }
182
            }
3220 mandeep.dh 183
 
7572 anupam.sin 184
            $('#user-orders tr, #orders-without-user tr').removeClass('selected');
3228 mandeep.dh 185
            $('#order-row-' + orderId).addClass('selected');
186
        }
187
    });
2714 vikas 188
}
189
 
3228 mandeep.dh 190
function loadLineInfo(domId, userId, itemId) {
191
    $.ajax({
192
        type : "GET",
193
        url : "/crm/user-line-info?userId=" + userId + "&itemId=" + itemId,
194
        success : function(response) {
195
            $('#' + domId).html(response);
196
            $('#user-cart tr').removeClass('selected');
197
            $('#cart-row-' + itemId).addClass('selected');
198
        }
199
    });
2830 vikas 200
}
201
 
3228 mandeep.dh 202
function loadTicketInfo(domId, ticketId, ticketTable, activityId) {
203
    $.ajax({
204
        type : "GET",
3405 mandeep.dh 205
        url : "/crm/tickets/" + ticketId + "/edit",
3228 mandeep.dh 206
        success : function(response) {
207
            $('#' + domId).html(response);
3206 mandeep.dh 208
 
3228 mandeep.dh 209
            var trId = 'ticket-row-' + ticketId;
210
            if (ticketTable != null) {
211
                for ( var index in ticketTable.fnGetNodes()) {
212
                    var item = ticketTable.fnGetNodes()[index];
213
                    if ($(item).attr('id') == trId) {
214
                        ticketTable.fnDisplayRow(item);
215
                        break;
216
                    }
217
                }
218
            }
3206 mandeep.dh 219
 
3228 mandeep.dh 220
            $('#tickets tr').removeClass('selected');
221
            $('#' + trId).addClass('selected');
222
 
223
            // For tickets accessed from activity page
224
            if (activityId != null) {
3339 mandeep.dh 225
                $('#activity tr').removeClass('selected');
3228 mandeep.dh 226
                $('#activity-row-' + activityId).addClass('selected');
227
            }
18348 amit.gupta 228
            $('#tr-table').dataTable({
229
            	"bAutoWidth": false,
230
          		"bLengthChange": false,
231
	            "bFilter": false,
232
            	"aoColumns" : [{ "sWidth": "8%" },
233
                	           { "sWidth": "8%" },
234
                    	       { "sWidth": "8%" },
19087 manish.sha 235
                        	   { "sWidth": "40%" },
236
                        	   { "sWidth": "10%" },
237
                        	   { "sWidth": "10%" },
238
                        	   { "sWidth": "8%" },
239
                        	   { "sWidth": "8%" }],
18348 amit.gupta 240
 
241
                "iDisplayLength" : 10,
242
                //"fnDrawCallback": function() {truncateText(100);},
18855 amit.gupta 243
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
18348 amit.gupta 244
            });
3546 mandeep.dh 245
 
246
            $('#order-table').dataTable({
18884 amit.gupta 247
 
18348 amit.gupta 248
                //"aaSorting" : [ [ 2, 'desc' ] ],
18345 amit.gupta 249
	            "bAutoWidth": false,
18886 amit.gupta 250
	            "aoColumns" : aoColumns[ordertype],
18345 amit.gupta 251
                //"iDisplayLength" : 10,
18348 amit.gupta 252
                "fnDrawCallback": function() {
253
	                $('.mk_transaction').click(function(){
254
 
255
	                });
256
                },
18855 amit.gupta 257
                "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
18345 amit.gupta 258
            });
3228 mandeep.dh 259
        }
260
    });
3090 mandeep.dh 261
}
262
 
3405 mandeep.dh 263
function createTicketDataTable(domId) {
3499 mandeep.dh 264
    var ticketsTable = $('#' + domId).dataTable({
4142 mandeep.dh 265
         "aaSorting" : [ [ 3, 'asc' ] ],
4241 anupam.sin 266
         "bAutoWidth": false,
267
         "aoColumns" : [{ "sWidth": "9%" },//ticket id
268
                        { "sWidth": "16%" },//customer id or Description when orderId is set
269
                        { "sWidth": "21%" },//category id
270
                        { "sWidth": "13%" },//date created
271
                        { "sWidth": "13%" },//date closed
272
                        { "sWidth": "12%" },//assignee
273
                        { "sWidth": "8%" },//status
274
                        { "sWidth": "8%" }],//priority
3546 mandeep.dh 275
        "fnDrawCallback": function() {truncateText(85);},
4605 anupam.sin 276
        "iDisplayLength" : 10,
3339 mandeep.dh 277
        "sDom" : 'T<"clear">lfrtip',
278
        "oTableTools" : {
5203 amar.kumar 279
            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf",
280
            "sExtends": "csv",
281
            "sFieldSeperator": "`"
3339 mandeep.dh 282
        },
283
        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
284
    });
3499 mandeep.dh 285
 
286
    return ticketsTable;
3339 mandeep.dh 287
}
288
 
4241 anupam.sin 289
function loadActivityDescription(domId, aActivityId) {
5521 amar.kumar 290
	if($(aActivityId).attr('isRead')=="true") {
291
		$('#' + domId).html("<h4>Activity Description :</h4><pre>" + $(aActivityId).parent().siblings('td[id="activity-description"]').attr('title') + '</pre>');
292
	} else {
293
		$('#' + domId).html("<h4>Activity Description :</h4><pre>" + $(aActivityId).parent().siblings('td[id="activity-description"]').attr('title') + 
294
				'</pre><br/><input type="button" value="Mark as read" activityid="'+ $(aActivityId).attr('activityid') +'" id="mark-as-read">');
295
	}
4241 anupam.sin 296
    $('#activity-table tr').removeClass('selected');
297
    $(aActivityId).parent().parent().addClass('selected');
298
}
299
 
3422 mandeep.dh 300
function loadActivityInfo(domId, activityId) {
3228 mandeep.dh 301
    $.ajax({
302
        type : "GET",
3422 mandeep.dh 303
        url : "/crm/activity-info?activityId=" + activityId,
3228 mandeep.dh 304
        success : function(response) {
305
            $('#' + domId).html(response);
3339 mandeep.dh 306
            $('#activity tr').removeClass('selected');
3228 mandeep.dh 307
            $('#activity-row-' + activityId).addClass('selected');
3390 mandeep.dh 308
            $('#activity').css('table-layout', 'fixed');
3228 mandeep.dh 309
        }
310
    });
3090 mandeep.dh 311
}
312
 
3405 mandeep.dh 313
function createActivityDataTable(domId) {
3499 mandeep.dh 314
    var activityTable = $('#' + domId).dataTable({
3339 mandeep.dh 315
        "aaSorting" : [ [ 4, 'desc' ] ],
4241 anupam.sin 316
     "bAutoWidth": false,
5203 amar.kumar 317
      "aoColumns" : [{ "sWidth": "7%" },//id
318
                     { "sWidth": "18%" },//activity type
319
                     { "sWidth": "11%" },//description
320
                     { "sWidth": "11%" },//timestamp
4241 anupam.sin 321
                     { "sWidth": "12%" },//creator
5203 amar.kumar 322
                     { "sWidth": "6%" },//customer id
323
                     { "sWidth": "7%" },//ticket id
324
                     { "sWidth": "7%" },//ticket status
325
                     { "sWidth": "12%" },//category
326
                     { "sWidth": "9%" }],//contact number
4605 anupam.sin 327
        "iDisplayLength" : 10,
3339 mandeep.dh 328
        "sDom" : 'T<"clear">lfrtip',
3546 mandeep.dh 329
        "fnDrawCallback": function() {truncateText(95);},
3339 mandeep.dh 330
        "oTableTools" : {
5203 amar.kumar 331
            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf",
332
            "sExtends": "csv",
333
            "sFieldSeperator": "`"
3339 mandeep.dh 334
        },
335
        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
336
    });
3499 mandeep.dh 337
 
338
    return activityTable;
3339 mandeep.dh 339
}
340
 
4793 amar.kumar 341
function loadAgentsInfo(domId) {
342
	$.ajax({
343
		type    : "GET",
344
		url	    : "/crm/agent",
345
		success : function(response) {
346
			$('#' + domId).html(response);
347
 
348
			var agentTable = $('#agents').dataTable({
349
                "aaSorting" : [ [ 1, 'asc' ] ],
350
                "bAutoWidth": false,
351
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
7162 kshitij.so 352
                               { "sWidth": "25%" },//Agent Name
353
                               { "sWidth": "30%" },//Email ID
354
                               { "sWidth": "20%" },//Role
4793 amar.kumar 355
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
356
                "iDisplayLength" : 10,
357
                "sDom" : 'T<"clear">lfrtip',
358
                "oTableTools" : {
359
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
360
                },
361
            });
362
		}
363
	});
364
}
365
 
5909 amar.kumar 366
function loadAllOpenTickets(domId) {
367
	$.ajax({
368
		type    : "GET",
369
		url	    : "/crm/tickets!getAllOpenTickets",
370
		success : function(response) {
371
			$('#' + domId).html(response);
372
 
373
			var agentTable = $('#open-tickets').dataTable({
374
                "aaSorting" : [ [ 1, 'asc' ] ],
375
                "bAutoWidth": true,
376
                "iDisplayLength" : 25,
377
                "sDom" : 'T<"clear">lfrtip',
378
                "oTableTools" : {
379
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
380
                },
381
            });
382
		}
383
	});
384
}
385
 
3405 mandeep.dh 386
function loadTicketCreationForm(domId, params) {
3228 mandeep.dh 387
    $.ajax({
388
        type : "GET",
3339 mandeep.dh 389
        url : "/crm/tickets/new",
3405 mandeep.dh 390
        data : params,
3339 mandeep.dh 391
        success : function(response) {
392
            $('#' + domId).html(response);
393
        }
394
    });
395
}
396
 
3405 mandeep.dh 397
function loadActivityCreationForm(domId, params) {
3339 mandeep.dh 398
    $.ajax({
399
        type : "GET",
400
        url : "/crm/activity/new",
3405 mandeep.dh 401
        data : params,
3339 mandeep.dh 402
        success : function(response) {
403
            $('#' + domId).html(response);
404
        }
405
    });
406
}
407
 
3090 mandeep.dh 408
function updateTicket(domId, ticketId, params) {
3228 mandeep.dh 409
    $.ajax({
4782 mandeep.dh 410
        type : "POST",
411
        url : "/crm/tickets!update?id=" + ticketId,
412
        data : params,
3228 mandeep.dh 413
        success : function(response) {
3339 mandeep.dh 414
            var ticketTable = $('table[id$="tickets"]');
415
            if (ticketTable.length == 1) {
416
                var rowIndex = ticketTable.dataTable().fnGetPosition($('tr#ticket-row-' + ticketId)[0]);
417
                var responseObj = jQuery(response);
3546 mandeep.dh 418
                var actionMessages = responseObj.find('#action-messages').html();
3339 mandeep.dh 419
                responseObj.find('#ticket-row-' + ticketId).children().each(
420
                        function(i, item) {
421
                            var th = responseObj.find('th').eq(i);
422
                            if (th.text() == "Ticket Id") {
423
                                return;
424
                            }
425
 
426
                            var thOld = ticketTable.find('th').filter(
427
                                    function(index) {
428
                                        if ($(this).text() == th.text()) {
429
                                            return true;
430
                                        }
431
 
432
                                        return false;
433
                                    });
434
 
4249 anupam.sin 435
                            if ($(thOld).length != 0) {
3339 mandeep.dh 436
                                ticketTable.dataTable().fnUpdate($(item).text(), rowIndex, $(thOld).index(), true, false);
437
                            }
438
                        });
439
 
3546 mandeep.dh 440
                loadTicketInfo("bottom-infopane", ticketId, ticketTable.dataTable(), null);
3339 mandeep.dh 441
                ticketTable.css('table-layout', 'fixed');
3546 mandeep.dh 442
 
443
                var alertString = jQuery.trim(actionMessages);
444
                if (alertString != '') {
445
                    alert(alertString);
446
                }
3339 mandeep.dh 447
            }
448
            else {
449
                loadTicketInfo("bottom-infopane", ticketId, null, null);
450
            }
451
 
3499 mandeep.dh 452
            truncateText(85);
3339 mandeep.dh 453
        }
454
    });
455
}
456
 
3090 mandeep.dh 457
function createTicket(domId, params) {
3228 mandeep.dh 458
    $.ajax({
459
        type : "POST",
3339 mandeep.dh 460
        url : "/crm/tickets",
3228 mandeep.dh 461
        data : params,
462
        success : function(response) {
463
            $('#' + domId).html(response);
3405 mandeep.dh 464
            var ticketTable = createTicketDataTable('tickets');
3228 mandeep.dh 465
        }
466
    });
3090 mandeep.dh 467
}
468
 
4793 amar.kumar 469
function createAgent(params, managerId){
470
	$.ajax({
471
		type : "POST",
472
		url : "/crm/agent!createAgent?managerId="+managerId,
473
		data : params,
474
		success : function(response) {
475
			alert("Agent created with the specified information");
476
			$.colorbox.close();
477
			$('#infopane').html(response);
478
			var agentTable = $('#agents').dataTable({
479
                "aaSorting" : [ [ 1, 'asc' ] ],
480
                "bAutoWidth": false,
481
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
7162 kshitij.so 482
                               { "sWidth": "25%" },//Agent Name
483
                               { "sWidth": "30%" },//Email ID
484
                               { "sWidth": "20%" },//Role
4793 amar.kumar 485
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
486
                "iDisplayLength" : 10,
487
                "sDom" : 'T<"clear">lfrtip',
488
                "oTableTools" : {
489
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
490
                },
491
            });
492
		}
493
	});
494
}
495
 
5168 amar.kumar 496
function changeAgentRole(params){
497
	$.ajax({
498
		type : "POST",
499
		url : "/crm/agent!changeAgentRole",
500
		data : params,
501
		success : function(response) {
502
			alert("Agent role changed");
503
			$.colorbox.close();
504
			$('#infopane').html(response);
505
			var agentTable = $('#agents').dataTable({
506
                "aaSorting" : [ [ 1, 'asc' ] ],
507
                "bAutoWidth": false,
508
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
7162 kshitij.so 509
                               { "sWidth": "25%" },//Agent Name
510
                               { "sWidth": "30%" },//Email ID
511
                               { "sWidth": "20%" },//Role
5168 amar.kumar 512
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
513
                "iDisplayLength" : 10,
514
                "sDom" : 'T<"clear">lfrtip',
515
                "oTableTools" : {
516
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
517
                },
518
            });
519
		}
520
	});
521
}
522
 
3090 mandeep.dh 523
function createActivity(domId, params) {
3228 mandeep.dh 524
    $.ajax({
525
        type : "POST",
3339 mandeep.dh 526
        url : "/crm/activity",
3228 mandeep.dh 527
        data : params,
528
        success : function(response) {
529
            $('#' + domId).html(response);
3405 mandeep.dh 530
            var activityTable = createActivityDataTable('activity');
3228 mandeep.dh 531
        }
532
    });
3106 mandeep.dh 533
}
534
 
535
function goToHomePage() {
3228 mandeep.dh 536
    document.location.href = "/crm";
3106 mandeep.dh 537
}
538
 
3422 mandeep.dh 539
function loadTickets(domId, getURL, ticketId) {
3228 mandeep.dh 540
    $.ajax({
541
        type : "GET",
3234 mandeep.dh 542
        url : getURL,
3228 mandeep.dh 543
        success : function(response) {
544
            $('#' + domId).html(response);
3405 mandeep.dh 545
            var ticketTable = createTicketDataTable('tickets');
3422 mandeep.dh 546
            if (ticketId != null) {
547
                loadTicketInfo("bottom-infopane", ticketId, ticketTable.dataTable(), null);
548
                ticketTable.css('table-layout', 'fixed');
549
            }
3228 mandeep.dh 550
        }
551
    });
3106 mandeep.dh 552
}
5225 amar.kumar 553
function changeActivityFormValidCriteria(commonDescription) {
554
	if(commonDescription == "") {
555
		$('#description').addClass('required');
556
	} else {
557
		$('#description').removeClass('required');
558
	}
559
}
3137 mandeep.dh 560
 
3422 mandeep.dh 561
function processActivityTypeChange(activityType) {
5203 amar.kumar 562
	if(activityType != "RECEIVED_CALL_FROM_CUSTOMER") {
563
		$('select#common-activity-desc').hide();
5224 amar.kumar 564
		$('#description').addClass('required');
5203 amar.kumar 565
	} else {
566
		$('select#common-activity-desc').show();
567
	}
3269 mandeep.dh 568
    if (activityType == "SEND_EMAIL_TO_CUSTOMER") {
3228 mandeep.dh 569
        $.colorbox({
570
            inline : true,
3519 mandeep.dh 571
            width : "775px",
572
            height : "445px",
3228 mandeep.dh 573
            href : "div#mail-div",
574
            onClosed : function() {
3519 mandeep.dh 575
				CKEDITOR.instances['mail-body'].destroy(false);
3228 mandeep.dh 576
                $("div#mail-div").hide();
577
                $('select#activity-type').val('OTHER');
578
            }
579
        });
3206 mandeep.dh 580
 
3228 mandeep.dh 581
        $("div#mail-div").show();
3701 mandeep.dh 582
        $('#mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
3228 mandeep.dh 583
    }
4020 mandeep.dh 584
    else if (activityType == "ESCALATE_TICKET") {
585
        $.colorbox({
586
            inline : true,
587
            width : "675px",
18308 amit.gupta 588
            height : "560px",
4020 mandeep.dh 589
            href : "div#escalation-div",
590
            onClosed : function() {
591
                CKEDITOR.instances['escalation-mail-body'].destroy(false);
592
                $("div#escalation-div").hide();
593
                $('select#activity-type').val('OTHER');
594
            }
595
        });
596
 
597
        $("div#escalation-div").show();
598
        $('#escalation-mail-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
599
    }
3206 mandeep.dh 600
}
601
 
602
function processInputFormSubmit() {
3228 mandeep.dh 603
    $.ajax({
604
        type : "POST",
605
        url : "/crm/",
606
        success : function(response) {
607
            $.html(response);
3405 mandeep.dh 608
            var ticketTable = createTicketDataTable('tickets');
3228 mandeep.dh 609
        }
610
    });
3339 mandeep.dh 611
}
612
 
613
function listActivities(domId, params) {
614
    $.ajax({
615
        type : "GET",
616
        url : "/crm/activity",
617
        data : params,
618
        success : function(response) {
619
            $('#' + domId).html(response);
3405 mandeep.dh 620
            var activityTable = createActivityDataTable('activity');
3339 mandeep.dh 621
        }
622
    });
623
}
624
 
18345 amit.gupta 625
function truncateText(widthSize, jqueryContainer) {
626
	if(typeof jqueryContainer!="undefined"){
627
	    jqueryContainer.find(".truncated-text").each(function() {
628
	    	$(this).truncate({
629
	            width : $(this).attr('truncatedTextWidth'),
630
	            addtitle : true
631
	        });
632
		})
633
	}else {
634
	    $(".truncated-text").each(function() {
635
	    	$(this).truncate({
636
	            width : $(this).attr('truncatedTextWidth'),
637
	            addtitle : true
638
	        });
639
		})
640
	}
3339 mandeep.dh 641
}
3390 mandeep.dh 642
 
643
function markAsRead(activityId) {
644
    $.ajax({
645
        type : "POST",
646
        url : "/crm/activity!markAsRead?activityId=" + activityId,
647
        success: function(response) {
648
            listActivities('infopane', "creatorId=1");
649
        }
650
    });
651
}
3397 mandeep.dh 652
 
653
function loadAdvancedSearchBox() {
654
    $.colorbox({
655
        inline : true,
656
        width : "535px",
657
        height : "465px",
658
        href : "form#search",
659
        onClosed : function() {
660
            $("form#search").hide();
661
        }
662
    });
663
 
664
    $("form#search").show();
665
}
666
 
667
function processSearchEntityChange(searchEntity) {
668
    if (searchEntity == "Tickets") {
669
        $("#assignee").show();
670
        $("#creator").hide();
4142 mandeep.dh 671
        $("tr#activityTypes").hide();
3397 mandeep.dh 672
    }
673
    else if (searchEntity == "Activities") {
674
        $("#assignee").hide();
675
        $("#creator").show();
4142 mandeep.dh 676
        $("tr#activityTypes").show();
3397 mandeep.dh 677
    }
678
}
3499 mandeep.dh 679
 
680
function increaseTrustLevel(domId, userId, trustLevelDelta) {
681
    $.ajax({
682
        type : "PUT",
683
        url : "/crm/user-info/" + userId + "?trustLevelDelta=" + trustLevelDelta,
684
        success : function(response) {
685
            $('#' + domId).html(response);
686
        }
687
    });
688
}
689
 
11890 kshitij.so 690
function addPrivateDealUser(domId, userId) {
691
    $.ajax({
692
        type : "PUT",
693
        url : "/crm/user-info!addPrivateDealUser?userId=" + userId,
694
        success : function(response) {
695
            $('#' + domId).html(response);
696
        }
697
    });
698
}
699
 
700
function changePrivateDealUserStatus(domId, userId, state) {
701
    $.ajax({
702
        type : "PUT",
703
        url : "/crm/user-info!changeStatusOfPrivateDealUser?userId=" + userId+ "&isPrivateDealUserActive=" + state,
704
        success : function(response) {
705
            $('#' + domId).html(response);
706
        }
707
    });
708
}
709
 
710
function resetPasswordForPrivateDealUser(domId, userId) {
711
    $.ajax({
712
        type : "PUT",
713
        url : "/crm/user-info!resetPrivateDealUserPassword?userId=" + userId,
714
        success : function(response) {
715
            $('#' + domId).html(response);
716
        },
717
    	error : function() {
718
    		alert("Unable to reset password.");
719
    	}
720
    });
721
}
722
 
19072 manish.sha 723
function displayCancelOrderPopUp(type) {
4241 anupam.sin 724
    	$.colorbox({
725
            inline : true,
726
            width : "650px",
4314 anupam.sin 727
            height : "550px",
4689 anupam.sin 728
            href : "div#cancel-div",
4241 anupam.sin 729
            onClosed : function() {
4689 anupam.sin 730
                CKEDITOR.instances['cancel-body'].destroy(false);
19072 manish.sha 731
                $("div#cancel-div").attr('cancelType','');
4689 anupam.sin 732
                $("div#cancel-div").hide();
4241 anupam.sin 733
            }
734
        });
19072 manish.sha 735
    	$("div#cancel-div").attr('cancelType',type);
4689 anupam.sin 736
        $("div#cancel-div").show();
737
        $('#cancel-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
4241 anupam.sin 738
}
739
 
7393 anupam.sin 740
function displayCancelStoreOrderPopUp() {
741
	$.colorbox({
742
        inline : true,
743
        width : "650px",
744
        height : "550px",
745
        href : "#cancel-store-order-div",
746
        onClosed : function() {
747
            CKEDITOR.instances['cancel-store-order-body'].destroy(false);
748
            $("#cancel-store-order-div").hide();
749
        }
750
    });
751
 
752
    $("#cancel-store-order-div").show();
753
    $('#cancel-store-order-body').ckeditor({toolbar : 'Basic', scayt_autoStartup : true});
754
}
755
 
4241 anupam.sin 756
function cancelOrder(domId, ticketId, orderId, orderStatus, formData) {
4704 anupam.sin 757
	if ($('#cancellationInitiator').val()) {
4689 anupam.sin 758
		var cancellationInitiator = $('#cancellationInitiator').val();
759
		var uri = "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId
760
						+ "&cancellationInitiator=" + cancellationInitiator + "&" + formData;
761
		var cancellationResult = function() {
762
			document.location.href = "/crm?email=&orderId=" + orderId;
763
		}
764
	} else {
765
		var uri = "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
766
						+ "&orderStatus=" + orderStatus + "&" + formData;
767
		var cancellationResult = function(response) {
768
            $('#' + domId).html(response);
769
        }
770
	}
4241 anupam.sin 771
    $.ajax({
772
        type : "POST",
4689 anupam.sin 773
        url : uri,
774
        success : cancellationResult
4241 anupam.sin 775
    });
4681 amar.kumar 776
 
777
    if(formData.indexOf("LOWER_PRICE_AVAILABLE_ELSEWHERE")!=-1){
778
    	var desc = formData.split("&");
779
    	var description = "Order cancelled because of Lower Price Available elsewhere";
780
    	$.ajax({
781
    		type : "POST",
782
    		url : "/crm/tickets?orderId="+orderId+"&priority=MEDIUM&category=PRODUCT_PROCUREMENT"
783
    				+ "&assigneeEmailId=chaitnaya.vats@shop2020.in&description="+description+"&"+desc[1],
784
    		success : function(response){
785
    			alert("Ticket created for Lower Price Available elsewhere");
786
    		}
787
    	});
788
 
789
    }
4241 anupam.sin 790
}
4065 mandeep.dh 791
 
7393 anupam.sin 792
function cancelStoreOrder(domId, ticketId, orderId, orderStatus, formData) {
793
	if ($('#cancellationInitiator').val() != "CUSTOMER" && $('#cancellationInitiator').val() != "INTERNAL") {
794
		alert("Cannot refund");
795
		return false;
796
	} 
797
	var cancellationInitiator = $('#cancellationInitiator').val();
798
	var uri = "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId
799
					+ "&cancellationInitiator=" + cancellationInitiator + "&" + formData;
800
	var cancellationResult = function() {
801
		document.location.href = "/crm?email=&orderId=" + orderId;
802
	}
803
 
804
    $.ajax({
805
        type : "POST",
806
        url : uri,
807
        success : cancellationResult
808
    });
809
}
810
 
4241 anupam.sin 811
function updateOrderStatus(domId, ticketId, orderId, orderStatus) {
3499 mandeep.dh 812
    $.ajax({
3546 mandeep.dh 813
        type : "POST",
4241 anupam.sin 814
        url : "/crm/tickets!updateOrderStatus?id=" + ticketId + "&orderId=" + orderId
815
        					+ "&orderStatus=" + orderStatus,
3499 mandeep.dh 816
        success : function(response) {
3546 mandeep.dh 817
            $('#' + domId).html(response);
3499 mandeep.dh 818
        }
819
    });
3711 mandeep.dh 820
}
821
 
822
function loadUnreadActivities(domId) {
823
    $.ajax({
824
        type : "GET",
825
        url : "/crm/activity!getUnreadActivities",
826
        success : function(response) {
827
            $('#' + domId).html(response);
828
            var activityTable = createActivityDataTable('activity');
829
        }
830
    });
831
}
4065 mandeep.dh 832
 
833
function refreshSidebar() {
834
    $.ajax({
4142 mandeep.dh 835
        type : "PUT",
836
        url : "/crm",
837
        success : function(response) {
838
            $('#sidebar').html($(response).find('#sidebar').html());
839
        }
840
    });
841
}
842
 
843
function changeAddress(urlParams) {
844
    $.ajax({
4065 mandeep.dh 845
        type : "GET",
846
        url : "/crm",
847
        success : function(response) {
848
            $('#sidebar').html($(response).find('#sidebar').html());
849
        }
850
    });
4267 anupam.sin 851
}
852
 
4681 amar.kumar 853
function showHidecancelReasonDiv(cancelReason){
4793 amar.kumar 854
	var reasonsToShowDiv = ['LOWER_PRICE_AVAILABLE_ELSEWHERE','OTHER','OUT_OF_STOCK','COLOR_OUT_OF_STOCK'];
855
	if(($.inArray(cancelReason, reasonsToShowDiv))!=-1){
4681 amar.kumar 856
		$('#cancelReasonBox').show();
857
	} else {
858
		$('#cancelReasonBox').hide();
859
	}
860
}
861
 
4438 anupam.sin 862
function blockPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 863
	$.ajax({
864
		type : "GET",
4451 anupam.sin 865
		url : "/crm/tickets!blockPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 866
		success : function(response) {
867
            $('#bottom-infopane').html(response);
868
        }
869
	});
870
}
871
 
4438 anupam.sin 872
function allowPayment(transactionId, ticketId, paymentId) {
4267 anupam.sin 873
	$.ajax({
874
		type : "GET",
4451 anupam.sin 875
		url : "/crm/tickets!allowPayment?transactionId=" + transactionId + "&id=" + ticketId + "&paymentId=" + paymentId,
4267 anupam.sin 876
		success : function(response) {
877
            $('#bottom-infopane').html(response);
878
        }
879
	});
4490 anupam.sin 880
}
881
 
882
function denyDOA(orderId, ticketId) {
883
	$.ajax({
884
		type : "GET",
885
		url : "/crm/tickets!denyDOA?orderId=" + orderId + "&id=" + ticketId,
886
		success : function(response) {
887
            $('#bottom-infopane').html(response);
888
        }
889
	});
890
}
891
 
892
 
893
function authorizeDOA(orderId, ticketId) {
894
	$.ajax({
895
		type : "GET",
896
		url : "/crm/tickets!authorizeDOA?orderId=" + orderId + "&id=" + ticketId,
897
		success : function(response) {
898
            $('#bottom-infopane').html(response);
899
        }
900
	});
901
}
902
 
903
function denyReturn(orderId, ticketId) {
904
	$.ajax({
905
		type : "GET",
906
		url : "/crm/tickets!denyReturn?orderId=" + orderId + "&id=" + ticketId,
907
		success : function(response) {
908
            $('#bottom-infopane').html(response);
909
        }
910
	});
911
}
912
 
913
 
914
function authorizeReturn(orderId, ticketId) {
915
	$.ajax({
916
		type : "GET",
917
		url : "/crm/tickets!authorizeReturn?orderId=" + orderId + "&id=" + ticketId,
918
		success : function(response) {
919
            $('#bottom-infopane').html(response);
920
        }
921
	});
4689 anupam.sin 922
}
923
 
924
function markOrderForCancellation(orderId, formData) {
925
	console.log(typeof(orderId), typeof(formData), orderId, formData);
926
 
927
	$.ajax({
928
		type : "GET",
929
		url : "/crm/user-order-info!markOrderForCancellation?orderId=" + orderId + "&cancellationInitiator=" + formData,
930
		success : function(response) {
931
			document.location.href = "/crm?email=&orderId=" + orderId;
932
        }
933
	});
4793 amar.kumar 934
}
935
 
936
function loadAgentCreationForm() {
937
	$.colorbox({
938
        inline : true,
939
        width : "550px",
940
        height : "400px",
941
        href : "div#create-agent-div",
942
        onClosed : function() {
943
            $("div#create-agent-div").hide();
944
        }
945
    });
946
 
947
    $("div#create-agent-div").show();
948
 
949
}
950
 
951
function deactivateAgentPopup() {
952
	$.colorbox({
953
        inline : true,
954
        width : "400px",
955
        height : "150px",
956
        href : "div#deactivate-agent-div",
957
        onClosed : function() {
958
            $("div#deactivate-agent-div").hide();
959
        }
960
    });
961
 
962
    $("div#deactivate-agent-div").show();
963
 
964
}
965
 
966
function changeAgentPasswordPopup(){
967
	$.colorbox({
968
        inline : true,
969
        width  : "350px",
970
        height : "350px",
971
        href   : "div#change-password-div",
972
        onClosed : function() {
973
            $("div#change-password-div").hide();
974
        }
975
    });
976
 
977
    $("div#change-password-div").show();
978
}
979
 
5168 amar.kumar 980
function changeAgentRolePopup(){
981
	$.colorbox({
982
        inline : true,
983
        width  : "375px",
984
        height : "350px",
985
        href   : "div#change-agent-role-div",
986
        onClosed : function() {
987
            $("div#change-agent-role-div").hide();
988
        }
989
    });
4793 amar.kumar 990
 
5168 amar.kumar 991
    $("div#change-agent-role-div").show();
992
}
993
 
4793 amar.kumar 994
function updateAgentPassword(){
995
	if(($('#change-password1').val().trim())==($('#change-password2').val().trim())){
996
		$.ajax({
997
			type : "POST",
998
			url : "/crm/agent!changePassword?emailId=" + $('#agentEmail').val() + "&newPassword=" + $('#change-password1').val().trim(),
999
			success : function(response) {
1000
				alert("Password updated successfully");
1001
				$.colorbox.close();
1002
			}
1003
		});
1004
	}
1005
	else { 
1006
		alert("Passwords not matching");
1007
		return false;
1008
	}
1009
}
1010
 
1011
function validateAgentCreationForm(){
1012
	var formError = false;
1013
	if($('#new-agent-name').val().length == 0) {
1014
		$('#agent-name-error').html("Please enter the name");
1015
		$('#new-agent-name').addClass('agent-form-error');
1016
		formError = true;
1017
	}
1018
	if(($('#new-agent-id').val().length == 0)) {
1019
		$('#agent-email-error').html("Please enter the Email-ID");
1020
		$('#new-agent-id').addClass('agent-form-error');
1021
		formError = true;
1022
	}
1023
	if($('#create-password1').val().length == 0) {
1024
		$('#agent-password1-error').html("Please enter password");
1025
		$('#create-password1').addClass('agent-form-error');
1026
		formError = true;
1027
	} else if($('#create-password2').val().length == 0){
1028
		$('#agent-password2-error').html("Please re enter password");
1029
		$('#create-password2').addClass('agent-form-error');
1030
		formError = true;
1031
	} else if($('#create-password1').val()!=$('#create-password2').val()) {
1032
		$('#agent-password1-error').html("Please make sure you entered same passwords");
1033
		$('#create-password1').addClass('agent-form-error');
1034
		$('#create-password2').addClass('agent-form-error');
1035
		formError = true;
1036
	}
1037
 
1038
	if(formError){
1039
		return false;
1040
	}
1041
	return true;
1042
}
1043
 
1044
function clearAgentCreationForm() {
1045
		$('#agent-name-error').html("");
1046
		$('#new-agent-name').removeClass('agent-form-error');
1047
		$('#agent-email-error').html("");
1048
		$('#new-agent-id').removeClass('agent-form-error');
1049
		$('#agent-password1-error').html("");
1050
		$('#create-password1').removeClass('agent-form-error');
1051
		$('#agent-password2-error').html("");
1052
		$('#create-password2').removeClass('agent-form-error');
1053
		$('#agent-password1-error').html("");
1054
		$('#create-password1').removeClass('agent-form-error');
1055
		$('#create-password2').removeClass('agent-form-error');
1056
}
1057
 
1058
function deactivateAgent(emailId, id) {
1059
	$.ajax({
1060
		type : "POST",
1061
		url : "/crm/agent!deActivateAgent?emailId=" + emailId+ "&id=" + id,
7162 kshitij.so 1062
		success : function(response) { 
1063
			alert("Agent deactivated successfully");
4793 amar.kumar 1064
			$.colorbox.close();
1065
			$('#infopane').html(response);
1066
			var agentTable = $('#agents').dataTable({
1067
                "aaSorting" : [ [ 1, 'asc' ] ],
1068
                "bAutoWidth": false,
1069
                "aoColumns" : [{ "sWidth": "12%", "sSortDataType": "dom-text", "sType": "numeric" },//AgentID
7162 kshitij.so 1070
                               { "sWidth": "25%" },//Agent Name
1071
                               { "sWidth": "30%" },//Email ID
1072
                               { "sWidth": "20%" },//Role
4793 amar.kumar 1073
                               { "sWidth": "13%", "sSortDataType": "dom-text", "sType": "numeric"}],//Manager ID
1074
                "iDisplayLength" : 10,
1075
                "sDom" : 'T<"clear">lfrtip',
1076
                "oTableTools" : {
1077
                    "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
1078
                },
1079
            });
1080
		}
1081
	});
5791 anupam.sin 1082
}
1083
 
5917 anupam.sin 1084
function extendExpiryDate(domId, ticketId, orderId, pickupExtension) {
5791 anupam.sin 1085
    $.ajax({
1086
        type : "POST",
5917 anupam.sin 1087
        url : "/crm/tickets!extendExpiry?id=" + ticketId + "&orderId=" + orderId + "&pickupExtension=" + pickupExtension,
5791 anupam.sin 1088
        success : function(response) {
1089
            $('#' + domId).html(response);
1090
        }
1091
    });
6507 anupam.sin 1092
}
1093
 
1094
function refundRechargeOrder(rechargeOrderId, domId) {
1095
	$.ajax({
1096
        type : "POST",
1097
        url : "/crm/recharge-order-info!refundRechargeOrder?rechargeOrderId=" + rechargeOrderId,
1098
        success : function(response) {
6516 anupam.sin 1099
        	location.reload();
6507 anupam.sin 1100
        },
1101
        error : function() {
1102
        	$('#' + domId).html("<div style='padding:15px 5px 15px 5px;color:red;'><b>Error in refunding. " +
1103
        			"<a href='/crm/?email=&mobileNumber=&orderId=&ticketId=&rechargeOrderId=" + rechargeOrderId + "&deviceNumber=&submit=Search'>Try again</a> or contact Engineering team.</b></div>");
1104
        }
1105
    });
6985 anupam.sin 1106
}
1107
 
7730 anupam.sin 1108
function convertStoreToNormal(orderId) {
1109
	$.ajax({
1110
        type : "POST",
7732 anupam.sin 1111
        url : "/crm/user-order-info!convertStoreToNormal?orderId=" + orderId,
7730 anupam.sin 1112
        success : function() {
1113
        	location.reload();
1114
        },
1115
        error: function() {
1116
        	location.reload();
1117
        }
1118
    });
1119
}
1120
 
6985 anupam.sin 1121
function changeShippingAddress(orderId) {
1122
	$.ajax({
1123
        type : "POST",
1124
        url : "/crm/user-order-info!changeShippingAddress?orderId=" + orderId,
1125
        data : $('#shippingAddressFrm').serialize(),
1126
        success : function(response) {
1127
        	location.reload();
1128
        },
1129
        error : function() {
1130
        	location.reload();
1131
        }
1132
    });
7372 kshitij.so 1133
}
7572 anupam.sin 1134
 
8821 manish.sha 1135
function refundOrderPayment(params) {
1136
	$.ajax({
1137
        type : "POST",
1138
        url : "/crm/user-order-info!refundOrderPayment",
1139
        data : params,
1140
        success : function(response) {
1141
			alert(response);
1142
			location.reload();
1143
        },
1144
        error : function() {
1145
        	alert("Error in refund");
1146
        	location.reload();
1147
        }
1148
    });
1149
}
1150
 
7572 anupam.sin 1151
function loadOrdersByMobile(domId) {
1152
    orderTable = $('#orders-without-user').dataTable({
1153
      "aaSorting" : [ [ 1, 'desc' ] ],
1154
      "bAutoWidth": false,
11890 kshitij.so 1155
      "aoColumns" : [{ "sWidth": "5%" },//order id
1156
                     { "sWidth": "7%" },//Source
1157
                     { "sWidth": "20%" },//item desc
7572 anupam.sin 1158
                     { "sWidth": "16%" },//created
1159
                     { "sWidth": "7%" },//amount
1160
                     { "sWidth": "15%" },//status
11890 kshitij.so 1161
                     { "sWidth": "10%" },//mobile no.
1162
                     { "sWidth": "20%" }],//email
18345 amit.gupta 1163
        "fnDrawCallback": function() { truncateText(125, $(this)); },
7572 anupam.sin 1164
        "iDisplayLength" : 10,
1165
        "sDom" : 'T<"clear">lfrtip',
1166
        "oTableTools" : {
1167
            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
1168
        },
1169
        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
1170
    });
9166 manish.sha 1171
}
1172
 
1173
function loadRechargeOrdersByDeviceNo(domId){
1174
	orderTable = $('#recharge-orders').dataTable({
1175
	      "aaSorting" : [ [ 1, 'desc' ] ],
1176
	      "bAutoWidth": false,
9174 manish.sha 1177
	      "aoColumns" : [{ "sWidth": "13%" },//recharge order id
1178
                         { "sWidth": "22%" },//desc
9166 manish.sha 1179
                         { "sWidth": "16%" },//created
1180
                         { "sWidth": "8%" },//amount
1181
                         { "sWidth": "17%" },//status
9174 manish.sha 1182
                         { "sWidth": "10%" },//mobile no.
1183
                         { "sWidth": "14% "}],//email Id
9166 manish.sha 1184
	        "fnDrawCallback": function() { truncateText(125); },
1185
	        "iDisplayLength" : 10,
1186
	        "sDom" : 'T<"clear">lfrtip',
1187
	        "oTableTools" : {
1188
	            "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
1189
	        },
1190
	        "aLengthMenu" : [ [ 5, 10, 20, -1 ], [ 5, 10, 20, "All" ] ]
1191
	    });
19072 manish.sha 1192
}
1193
 
1194
/*function loadReturnTxnsInfo(domId){
1195
	$.ajax({
1196
		type    : "GET",
1197
		url	    : "/crm/return-transaction",
1198
		success : function(response) {
1199
			$('#' + domId).html(response);
1200
		}
1201
	});
1202
}*/
1203
 
1204
function updateTxnStatus(domId, ticketId, transactionId, orderStatus) {
1205
	$.ajax({
1206
        type : "POST",
1207
        url : "/crm/tickets!updateTxnStatus?id=" + ticketId + "&transactionId=" + transactionId
1208
        					+ "&orderStatus=" + orderStatus,
1209
        success : function(response) {
1210
            $('#' + domId).html(response);
1211
        }
1212
    });
1213
}
1214
 
1215
function cancelTxn(domId, ticketId, transactionId, orderStatus, formData) {
1216
 
1217
	var uri = "/crm/tickets!updateTxnStatus?id=" + ticketId + "&transactionId=" + transactionId
1218
					+ "&orderStatus=" + orderStatus + "&" + formData;
1219
	var cancellationResult = function(response) {
1220
        $('#' + domId).html(response);
1221
    }
1222
 
1223
    $.ajax({
1224
        type : "POST",
1225
        url : uri,
1226
        success : cancellationResult
1227
    });
7572 anupam.sin 1228
}