Pman.Tab.MTrackMilestone.js
[Pman.MTrack] / Pman.Tab.MTrackMilestone.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '200-Pman.Tab.MTrackMilestone',
12         module : Pman.Tab.MTrackMilestone,
13         region : 'center',
14         parent : Pman.Tab.MTrack,
15         name : "Pman.Tab.MTrackMilestone",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.MTrackMilestone = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'GridPanel',
35             xns: Roo,
36             listeners : {
37                 activate : function() {
38                     _this.panel = this;
39                     if (_this.grid) {
40                         _this.grid.footer.onClick('first');
41                     }
42                 }
43             },
44             background : true,
45             fitContainer : true,
46             fitToframe : true,
47             region : 'center',
48             tableName : 'mtrack_milestone',
49             title : "Milestones",
50             grid : {
51                 xtype: 'Grid',
52                 xns: Roo.grid,
53                 autoExpandColumn : 'name',
54                 loadMask : true,
55                 listeners : {
56                     render : function() 
57                     {
58                         _this.grid = this; 
59                         //_this.dialog = Pman.Dialog.FILL_IN
60                         if (_this.panel.active) {
61                            this.footer.onClick('first');
62                         }
63                     },
64                     rowdblclick : function (_self, rowIndex, e)
65                     {
66                         if (!_this.dialog) return;
67                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
68                             _this.grid.footer.onClick('first');
69                         }); 
70                     }
71                 },
72                 dataSource : {
73                     xtype: 'Store',
74                     xns: Roo.data,
75                     listeners : {
76                         beforeload : function (_self, options)
77                         {
78                             options.params._with_active_tickets = 1;
79                         }
80                     },
81                     remoteSort : true,
82                     sortInfo : { field : 'duedate', direction: 'ASC' },
83                     proxy : {
84                         xtype: 'HttpProxy',
85                         xns: Roo.data,
86                         method : 'GET',
87                         url : baseURL + '/Roo/mtrack_milestone.php'
88                     },
89                     reader : {
90                         xtype: 'JsonReader',
91                         xns: Roo.data,
92                         totalProperty : 'total',
93                         root : 'data',
94                         id : 'id',
95                         fields : [
96                             {
97                                 'name': 'id',
98                                 'type': 'int'
99                             },
100                             {
101                                 'name': 'name',
102                                 'type': 'string'
103                             },
104                             {
105                                 'name': 'description',
106                                 'type': 'string'
107                             },
108                             {
109                                 'name': 'startdate',
110                                 'type': 'date',
111                                 'dateFormat': 'Y-m-d'
112                             },
113                             {
114                                 'name': 'duedate',
115                                 'type': 'date',
116                                 'dateFormat': 'Y-m-d'
117                             },
118                             {
119                                 'name': 'completed',
120                                 'type': 'date',
121                                 'dateFormat': 'Y-m-d'
122                             },
123                             {
124                                 'name': 'deleted',
125                                 'type': 'int'
126                             },
127                             {
128                                 'name': 'created',
129                                 'type': 'int'
130                             },
131                             {
132                                 'name': 'updated',
133                                 'type': 'int'
134                             },
135                             {
136                                 'name': 'project_id',
137                                 'type': 'int'
138                             },
139                             {
140                                 'name': 'deleted_id',
141                                 'type': 'int'
142                             },
143                             {
144                                 'name': 'deleted_person_id',
145                                 'type': 'int'
146                             },
147                             {
148                                 'name': 'deleted_ontable',
149                                 'type': 'string'
150                             },
151                             {
152                                 'name': 'deleted_onid',
153                                 'type': 'int'
154                             },
155                             {
156                                 'name': 'deleted_changedate',
157                                 'type': 'date'
158                             },
159                             {
160                                 'name': 'deleted_reason',
161                                 'type': 'string'
162                             },
163                             {
164                                 'name': 'updated_id',
165                                 'type': 'int'
166                             },
167                             {
168                                 'name': 'updated_person_id',
169                                 'type': 'int'
170                             },
171                             {
172                                 'name': 'updated_ontable',
173                                 'type': 'string'
174                             },
175                             {
176                                 'name': 'updated_onid',
177                                 'type': 'int'
178                             },
179                             {
180                                 'name': 'updated_changedate',
181                                 'type': 'date'
182                             },
183                             {
184                                 'name': 'updated_reason',
185                                 'type': 'string'
186                             },
187                             {
188                                 'name': 'created_id',
189                                 'type': 'int'
190                             },
191                             {
192                                 'name': 'created_person_id',
193                                 'type': 'int'
194                             },
195                             {
196                                 'name': 'created_ontable',
197                                 'type': 'string'
198                             },
199                             {
200                                 'name': 'created_onid',
201                                 'type': 'int'
202                             },
203                             {
204                                 'name': 'created_changedate',
205                                 'type': 'date'
206                             },
207                             {
208                                 'name': 'created_reason',
209                                 'type': 'string'
210                             }
211                         ]
212                     }
213                 },
214                 footer : {
215                     xtype: 'PagingToolbar',
216                     xns: Roo,
217                     pageSize : 25,
218                     displayInfo : true,
219                     displayMsg : 'Displaying mtrack_milestone{0} - {1} of {2}',
220                     emptyMsg : 'No mtrack_milestone found'
221                 },
222                 toolbar : {
223                     xtype: 'Toolbar',
224                     xns: Roo,
225                     items : [
226                         {
227                             xtype: 'Fill',
228                             xns: Roo.Toolbar
229                         },
230                         {
231                             xtype: 'Button',
232                             xns: Roo.Toolbar,
233                             text : "Add",
234                             cls : 'x-btn-text-icon',
235                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
236                             listeners : {
237                                 click : function()
238                                 {
239                                     if (!_this.dialog) return;
240                                     _this.dialog.show( { id : 0 } , function() {
241                                         _this.grid.footer.onClick('first');
242                                    }); 
243                                 }
244                             }
245                         },
246                         {
247                             xtype: 'Button',
248                             xns: Roo.Toolbar,
249                             text : "Edit",
250                             cls : 'x-btn-text-icon',
251                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
252                             listeners : {
253                                 click : function()
254                                 {
255                                     var s = _this.grid.getSelectionModel().getSelections();
256                                     if (!s.length || (s.length > 1))  {
257                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
258                                         return;
259                                     }
260                                     if (!_this.dialog) return;
261                                     _this.dialog.show(s[0].data, function() {
262                                         _this.grid.footer.onClick('first');
263                                     }); 
264                                     
265                                 }
266                             }
267                         },
268                         {
269                             xtype: 'Button',
270                             xns: Roo.Toolbar,
271                             listeners : {
272                                 click : function()
273                                         {
274                                         Pman.genericDelete(_this, 'mtrack_milestone'); 
275                                         }
276                             },
277                             cls : 'x-btn-text-icon',
278                             text : "Delete",
279                             icon : rootURL + '/Pman/templates/images/trash.gif'
280                         }
281                     ]
282                 },
283                 colModel : [
284                     {
285                         xtype: 'ColumnModel',
286                         xns: Roo.grid,
287                         dataIndex : 'project_id_name',
288                         header : 'Project',
289                         width : 150,
290                         renderer : function(v) { return String.format('{0}', v); }
291                     },
292                     {
293                         xtype: 'ColumnModel',
294                         xns: Roo.grid,
295                         dataIndex : 'active_tickets',
296                         header : '#Tickets',
297                         width : 50,
298                         renderer : function(v) { return String.format('{0}', v); }
299                     },
300                     {
301                         xtype: 'ColumnModel',
302                         xns: Roo.grid,
303                         header : 'Name',
304                         width : 200,
305                         dataIndex : 'name',
306                         renderer : function(v) { return String.format('{0}', v); }
307                     },
308                     {
309                         xtype: 'ColumnModel',
310                         xns: Roo.grid,
311                         header : 'Description',
312                         width : 200,
313                         dataIndex : 'description',
314                         renderer : function(v) { return String.format('{0}', v); }
315                     },
316                     {
317                         xtype: 'ColumnModel',
318                         xns: Roo.grid,
319                         header : 'Startdate',
320                         width : 75,
321                         dataIndex : 'startdate',
322                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
323                     },
324                     {
325                         xtype: 'ColumnModel',
326                         xns: Roo.grid,
327                         header : 'Duedate',
328                         width : 75,
329                         dataIndex : 'duedate',
330                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
331                     },
332                     {
333                         xtype: 'ColumnModel',
334                         xns: Roo.grid,
335                         header : 'Completed',
336                         width : 75,
337                         dataIndex : 'completed',
338                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
339                     }
340                 ]
341             }
342         });
343         this.layout = this.panel.layout;
344
345     }
346 });