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