Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
4755 amit.gupta 1
// increase the default animation speed to exaggerate the effect
2
jQuery.fx.speeds._default = 1000;
3
$(function() {
4
 
5
 
6
 
7
	$('.category').live('click', function() {
8
	    var categoryid = $(this).attr('id') + "-table";
9
		alert("Toggle style for category" + categoryid);
10
		$('.category-table').hide();
11
		$('#'+categoryid).show();
12
		return false;
13
	});
14
 
15
	$('.delete').live('click', function() {
16
		var entityid = $(this).attr('id');
17
        $('#dialog').dialog({
18
                    autoOpen: false,
19
    				width: 470,
20
            	    height: 100,
21
                    modal: true,
22
    				title: 'Are you sure ? It will be permanently deleted. Continue ?',
23
                    buttons: {
24
                    "OK":function() { window.location.href = "/content/entity/" + entityid + "?_method=delete" },
25
                    "Cancel": function() { $(this).dialog("close"); }
26
            }
27
         });
28
 
29
		$('#dialog').dialog('open');
30
 
31
		return false;
32
	});
5012 amit.gupta 33
	$('.clone').live('click', function() {
34
		var entityid = $(this).attr('id');
35
		$('#dialog-duplicate').dialog({
36
			autoOpen: false,
37
			width: 470,
38
			height: 300,
39
			modal: true,
40
			title: 'Enter the entity id',
41
			buttons: {
42
				"OK":function() { 
43
					var entityOld = $('#dup-entity').val();
44
					var patt=/^[0-9]{7}$/; 
45
					if(patt.test(entityOld)){
46
					window.location.href = 	"/content/item-update/" + entityid + 
47
											"?_method=put&action=dup-entity&entity-old=" + entityOld;
48
					}else {
49
						alert("Please enter a valid entity id.")
50
					}
51
				},
52
				"Cancel": function() { $(this).dialog("close"); }
53
			}
54
		});
55
 
56
		$('#dialog-duplicate').dialog('open');
57
 
58
		return false;
59
	});
4755 amit.gupta 60
 
61
	$('.complete').live('click', function() {
62
		var entityid = $(this).attr('id');
63
        $('#dialog').dialog({
64
                    autoOpen: false,
65
    				width: 470,
66
            	    height: 100,
67
                    modal: true,
68
    				title: 'The item will be completed, you will not be able to make further changes.  Continue?',
69
                    buttons: {
70
                    "OK":function() { window.location.href = "/content/item-update/" + entityid + "?_method=put&action=complete" },
71
                    "Cancel": function() { $(this).dialog("close"); }
72
            }
73
         });
74
 
75
		$('#dialog').dialog('open');
76
 
77
		return false;
78
	});
79
 
80
 
81
    $('.ready').live('click', function() {
82
		var entityid = $(this).attr('id');
83
        $('#dialog').dialog({
84
                    autoOpen: false,
85
    				width: 470,
86
            	    height: 100,
87
                    modal: true,
88
    				title: 'The item will become available for consumers to place orders for. Continue?',
89
                    buttons: {
90
                    "OK":function() { window.location.href = "/content/item-update/" + entityid + "?_method=put&action=ready" },
91
                    "Cancel": function() { $(this).dialog("close"); }
92
            }
93
         });
94
 
95
		$('#dialog').dialog('open');
96
 
97
		return false;
98
	});
99
 
100
 
101
	$('.assign').live('click', function() {
102
		var entityid = $(this).attr('id');
103
 
104
        $('#dialog-form').dialog({
105
                    autoOpen: false,
106
    				width: 470,
107
            	    height: 400,
108
                    modal: true,
109
					title: 'The item will be assigned. Are you sure ?',
110
                    buttons: {
111
                    "OK":function() {
112
					var username = $('#username').val();
113
						window.location.href = "/content/item-update/" + entityid + "?_method=put&action=assign&username=" + username; 
114
					},
115
                    "Cancel": function() { $(this).dialog("close"); }
116
            }
117
         });
118
 
119
		$('#dialog-form').dialog('open');
120
 
121
		return false;
122
	});
123
 
124
 
125
});
126
 
127
function renderActionTable(obj){
128
	 var entityId = obj.aData[ obj.iDataColumn ];
129
     var table = [];
130
     table.push('<span style="padding:2px"><a href="/content/entity/' + entityId + '" target="_blank">View</a></span>');
131
     table.push('<span style="border-left:1px solid black; padding:2px"><a href=""  id="' + entityId + '" class="delete">Delete</a></span>');
132
     table.push('<span style="border-left:1px solid black; padding:2px"><a href=""  id="' + entityId + '" class="ready">Approve</a></span>');
133
     table.push('<span style="border-left:1px solid black; padding:2px"><a href=""  id="' + entityId + '" class="complete">Complete</a></span>');
134
     table.push('<span style="border-left:1px solid black; padding:2px"><a href=""  id="' + entityId + '" class="assign">Assign</a></span>');
5012 amit.gupta 135
     table.push('<span style="border-left:1px solid black; padding:2px"><a href=""  id="' + entityId + '" class="clone">Clone</a></span>');
4755 amit.gupta 136
     return table.join("");		
137
}
138
 
139
$(document).ready(function() 
140
    { 
141
	var oTable = $("#myTable").dataTable({
142
						"aaSorting": [[ 1, "desc" ]],
19600 amit.gupta 143
						"iDisplayLength": 500,
4755 amit.gupta 144
						"bSort": false,
145
						"bDeferRender" : true,
146
						"sPaginationType": "full_numbers",
147
						"sDom": '<"wrapper"flipt>',
19600 amit.gupta 148
						"aaData": Entity.arr,
19603 amit.gupta 149
						"aLengthMenu" :[ 25,50,100,500 ],						
4755 amit.gupta 150
                        "aoColumns": [
151
                                     { "sTitle": "#" },
152
                                     { 
153
                                    	 "sTitle": "Entity ID",
154
                                    	 "fnRender" : function(obj){
155
                                    		 var entityId = obj.aData[ obj.iDataColumn ];
156
                                    		 return '<td><a href="/content/entity/' + entityId + '/edit">' + entityId + '</a></td>';
157
                                    	 }
158
                                     },
159
                                     { "sTitle": "Category" },
160
                                     { "sTitle": "Brand"},
161
                                     { "sTitle": "Model Name" },
162
                                     { "sTitle": "Model Number", "sClass": "center"  },
163
                                     { 
164
                                    	 "sTitle": "Item details",
165
                                    	 "fnRender" : function(obj){
166
                                    		 var entityId = obj.aData[ obj.iDataColumn ];
167
                                    		 return '<a class="details-from-catalog" entityId="' + entityId + 
168
                                    		 		'" href="#">see items</a>';
169
                                    	 }
170
                                     },
171
                                     { "sTitle": "Current Status" },
6877 amit.gupta 172
                                     { "sTitle": "Ready On" },
4755 amit.gupta 173
                                     { "sTitle": "Assigned To" },
174
                                     { "sTitle": "Completed By" },
175
                                     { 
176
                                    	 "sTitle": "Actions", 
177
                                    	 "sClass": "center",
5049 amit.gupta 178
                                    	 "fnRender": renderActionTable,
179
                                    	 "bSearchable" : false
4755 amit.gupta 180
                                     }
181
                                 ]
182
		});
19600 amit.gupta 183
    });
184
 
185
function exportEntities(){
186
	$("#myTable").tableExport({type:'csv',escape:'false', ignoreColumn:[0,6,7,8,9,10,11]});
187
}