Subversion Repositories SmartDukaan

Rev

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