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