Pman.Tab.AdminWatches.bjs
[Pman.Admin] / Pman.Tab.AdminWatches.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 : '860-Pman.Tab.AdminWatches',
12         module : Pman.Tab.AdminWatches,
13         region : 'center',
14         parent : Pman.Tab.Admin,
15         name : "Pman.Tab.AdminWatches",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.AdminWatches = 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             autoScroll : false,
45             background : true,
46             fitContainer : true,
47             fitToframe : true,
48             region : 'center',
49             tableName : 'core_watch',
50             title : "Watches",
51             grid : {
52                 xtype: 'Grid',
53                 xns: Roo.grid,
54                 listeners : {
55                     render : function() 
56                     {
57                         _this.grid = this; 
58                         _this.dialog = Pman.Dialog.AdminWatch;
59                         if (_this.panel.active) {
60                            this.footer.onClick('first');
61                         }
62                     },
63                     rowdblclick : function (_self, rowIndex, e)
64                     {
65                         if (!_this.dialog) return;
66                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
67                             _this.grid.footer.onClick('first');
68                         }); 
69                     }
70                 },
71                 autoExpandColumn : 'person_id_name',
72                 loadMask : true,
73                 dataSource : {
74                     xtype: 'Store',
75                     xns: Roo.data,
76                     listeners : {
77                         beforeload : function (_self, options)
78                         {
79                                 var val = _this.affectSel.getValue();
80                                 if (val.length) {
81                                     options.params.ontable = val;
82                                 }
83                                 
84                         }
85                     },
86                     remoteSort : true,
87                     sortInfo : { field : 'ontable', direction: 'ASC' },
88                     proxy : {
89                         xtype: 'HttpProxy',
90                         xns: Roo.data,
91                         method : 'GET',
92                         url : baseURL + '/Roo/core_watch.php'
93                     },
94                     reader : {
95                         xtype: 'JsonReader',
96                         xns: Roo.data,
97                         totalProperty : 'total',
98                         root : 'data',
99                         id : 'id',
100                         fields : [
101                             {
102                                 'name': 'id',
103                                 'type': 'int'
104                             },
105                             {
106                                 'name': 'ontable',
107                                 'type': 'string'
108                             },
109                             {
110                                 'name': 'onid',
111                                 'type': 'int'
112                             },
113                             {
114                                 'name': 'person_id',
115                                 'type': 'int'
116                             },
117                             {
118                                 'name': 'event',
119                                 'type': 'string'
120                             },
121                             {
122                                 'name': 'medium',
123                                 'type': 'string'
124                             },
125                             {
126                                 'name': 'active',
127                                 'type': 'int'
128                             },
129                             {
130                                 'name': 'person_id_id',
131                                 'type': 'int'
132                             },
133                             {
134                                 'name': 'person_id_office_id',
135                                 'type': 'int'
136                             },
137                             {
138                                 'name': 'person_id_name',
139                                 'type': 'string'
140                             },
141                             {
142                                 'name': 'person_id_phone',
143                                 'type': 'string'
144                             },
145                             {
146                                 'name': 'person_id_fax',
147                                 'type': 'string'
148                             },
149                             {
150                                 'name': 'person_id_email',
151                                 'type': 'string'
152                             },
153                             {
154                                 'name': 'person_id_company_id',
155                                 'type': 'int'
156                             },
157                             {
158                                 'name': 'person_id_role',
159                                 'type': 'string'
160                             },
161                             {
162                                 'name': 'person_id_active',
163                                 'type': 'int'
164                             },
165                             {
166                                 'name': 'person_id_remarks',
167                                 'type': 'string'
168                             },
169                             {
170                                 'name': 'person_id_passwd',
171                                 'type': 'string'
172                             },
173                             {
174                                 'name': 'person_id_owner_id',
175                                 'type': 'int'
176                             },
177                             {
178                                 'name': 'person_id_lang',
179                                 'type': 'string'
180                             },
181                             {
182                                 'name': 'person_id_no_reset_sent',
183                                 'type': 'int'
184                             },
185                             {
186                                 'name': 'person_id_action_type',
187                                 'type': 'string'
188                             },
189                             {
190                                 'name': 'person_id_project_id',
191                                 'type': 'int'
192                             },
193                             {
194                                 'name': 'person_id_deleted_by',
195                                 'type': 'int'
196                             },
197                             {
198                                 'name': 'person_id_deleted_dt',
199                                 'type': 'date'
200                             }
201                         ]
202                     }
203                 },
204                 footer : {
205                     xtype: 'PagingToolbar',
206                     xns: Roo,
207                     pageSize : 25,
208                     displayInfo : true,
209                     displayMsg : "Displaying core_watch{0} - {1} of {2}",
210                     emptyMsg : "No core_watch found"
211                 },
212                 toolbar : {
213                     xtype: 'Toolbar',
214                     xns: Roo,
215                     items : [
216                         {
217                             xtype: 'TextItem',
218                             xns: Roo.Toolbar,
219                             text : "Show"
220                         },
221                         {
222                             xtype: 'ComboBox',
223                             xns: Roo.form,
224                             listeners : {
225                                 select : function (combo, record, index)
226                                 {
227                                   _this.grid.footer.onClick('first');
228                                 },
229                                 render : function (_self)
230                                 {
231                                   _this.affectSel = _self;
232                                 }
233                             },
234                             allowBlank : true,
235                             displayField : 'ontable',
236                             editable : false,
237                             emptyText : "Select Table",
238                             forceSelection : true,
239                             listWidth : 300,
240                             loadingText : "Searching...",
241                             minChars : 2,
242                             name : 'ontable',
243                             pageSize : 20,
244                             qtip : "Select Action",
245                             queryParam : 'query[ontable]',
246                             selectOnFocus : true,
247                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{ontable}</b> </div>',
248                             triggerAction : 'all',
249                             typeAhead : true,
250                             valueField : 'ontable',
251                             width : 150,
252                             store : {
253                                 xtype: 'Store',
254                                 xns: Roo.data,
255                                 listeners : {
256                                     beforeload : function (_self, o)
257                                     {
258                                         o.params = o.params || {};
259                                         // staff can see all logs, other companies can only see their own.
260                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
261                                             o.params.company_id = Pman.Login.authUser.company_id;
262                                         }
263                                         o.params._distinct = 'on_table';
264                                         o.params._columns ='on_table';
265                                     }
266                                 },
267                                 remoteSort : true,
268                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
269                                 proxy : {
270                                     xtype: 'HttpProxy',
271                                     xns: Roo.data,
272                                     method : 'GET',
273                                     url : baseURL + '/Roo/Events.php'
274                                 },
275                                 reader : {
276                                     xtype: 'JsonReader',
277                                     xns: Roo.data,
278                                     id : 'id',
279                                     root : 'data',
280                                     totalProperty : 'total',
281                                     fields : [
282                                         {
283                                             'name': 'id',
284                                             'type': 'int'
285                                         },
286                                         {
287                                             'name': 'on_table',
288                                             'type': 'string'
289                                         }
290                                          
291                                     ]
292                                 }
293                             }
294                         },
295                         {
296                             xtype: 'Fill',
297                             xns: Roo.Toolbar
298                         },
299                         {
300                             xtype: 'Button',
301                             xns: Roo.Toolbar,
302                             text : "Add",
303                             cls : 'x-btn-text-icon',
304                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
305                             listeners : {
306                                 click : function()
307                                 {
308                                     if (!_this.dialog) return;
309                                     _this.dialog.show( { id : 0 } , function() {
310                                         _this.grid.footer.onClick('first');
311                                    }); 
312                                 }
313                             }
314                         },
315                         {
316                             xtype: 'Button',
317                             xns: Roo.Toolbar,
318                             text : "Edit",
319                             cls : 'x-btn-text-icon',
320                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
321                             listeners : {
322                                 click : function()
323                                 {
324                                     var s = _this.grid.getSelectionModel().getSelections();
325                                     if (!s.length || (s.length > 1))  {
326                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
327                                         return;
328                                     }
329                                     if (!_this.dialog) return;
330                                     _this.dialog.show(s[0].data, function() {
331                                         _this.grid.footer.onClick('first');
332                                     }); 
333                                     
334                                 }
335                             }
336                         },
337                         {
338                             xtype: 'Button',
339                             xns: Roo.Toolbar,
340                             text : "Delete",
341                             cls : 'x-btn-text-icon',
342                             icon : rootURL + '/Pman/templates/images/trash.gif',
343                             listeners : {
344                                 click : function()
345                                 {
346                                      Pman.genericDelete(_this, 'core_watch'); 
347                                 }
348                             }
349                         }
350                     ]
351                 },
352                 colModel : [
353                     {
354                         xtype: 'ColumnModel',
355                         xns: Roo.grid,
356                         dataIndex : 'event',
357                         header : 'Watch Event',
358                         width : 100,
359                         renderer : function(v) { return String.format('{0}', v); }
360                     },
361                     {
362                         xtype: 'ColumnModel',
363                         xns: Roo.grid,
364                         dataIndex : 'ontable',
365                         header : 'Watch Table',
366                         width : 150,
367                         renderer : function(v) { return String.format('{0}', v); }
368                     },
369                     {
370                         xtype: 'ColumnModel',
371                         xns: Roo.grid,
372                         dataIndex : 'onid',
373                         header : 'Watch ID',
374                         width : 75,
375                         renderer : function(v) { return String.format('{0}', v); }
376                     },
377                     {
378                         xtype: 'ColumnModel',
379                         xns: Roo.grid,
380                         dataIndex : 'person_id_name',
381                         header : 'Who get\'s notified',
382                         width : 150,
383                         renderer : function(v) { return String.format('{0}', v); }
384                     },
385                     {
386                         xtype: 'ColumnModel',
387                         xns: Roo.grid,
388                         dataIndex : 'medium',
389                         header : 'What happens',
390                         width : 200,
391                         renderer : function(v) { return String.format('{0}', v); }
392                     },
393                     {
394                         xtype: 'ColumnModel',
395                         xns: Roo.grid,
396                         header : 'Active',
397                         width : 75,
398                         dataIndex : 'active',
399                         renderer : function(v) { return String.format('{0}', v); }
400                     }
401                 ]
402             }
403         });
404         this.layout = this.panel.layout;
405
406     }
407 });