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.FILL_IN
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                     remoteSort : true,
76                     sortInfo : { field : 'ontable', direction: 'ASC' },
77                     proxy : {
78                         xtype: 'HttpProxy',
79                         xns: Roo.data,
80                         method : 'GET',
81                         url : baseURL + '/Roo/core_watch.php'
82                     },
83                     reader : {
84                         xtype: 'JsonReader',
85                         xns: Roo.data,
86                         totalProperty : 'total',
87                         root : 'data',
88                         id : 'id',
89                         fields : [
90                             {
91                                 'name': 'id',
92                                 'type': 'int'
93                             },
94                             {
95                                 'name': 'ontable',
96                                 'type': 'string'
97                             },
98                             {
99                                 'name': 'onid',
100                                 'type': 'int'
101                             },
102                             {
103                                 'name': 'person_id',
104                                 'type': 'int'
105                             },
106                             {
107                                 'name': 'event',
108                                 'type': 'string'
109                             },
110                             {
111                                 'name': 'medium',
112                                 'type': 'string'
113                             },
114                             {
115                                 'name': 'active',
116                                 'type': 'int'
117                             },
118                             {
119                                 'name': 'person_id_id',
120                                 'type': 'int'
121                             },
122                             {
123                                 'name': 'person_id_office_id',
124                                 'type': 'int'
125                             },
126                             {
127                                 'name': 'person_id_name',
128                                 'type': 'string'
129                             },
130                             {
131                                 'name': 'person_id_phone',
132                                 'type': 'string'
133                             },
134                             {
135                                 'name': 'person_id_fax',
136                                 'type': 'string'
137                             },
138                             {
139                                 'name': 'person_id_email',
140                                 'type': 'string'
141                             },
142                             {
143                                 'name': 'person_id_company_id',
144                                 'type': 'int'
145                             },
146                             {
147                                 'name': 'person_id_role',
148                                 'type': 'string'
149                             },
150                             {
151                                 'name': 'person_id_active',
152                                 'type': 'int'
153                             },
154                             {
155                                 'name': 'person_id_remarks',
156                                 'type': 'string'
157                             },
158                             {
159                                 'name': 'person_id_passwd',
160                                 'type': 'string'
161                             },
162                             {
163                                 'name': 'person_id_owner_id',
164                                 'type': 'int'
165                             },
166                             {
167                                 'name': 'person_id_lang',
168                                 'type': 'string'
169                             },
170                             {
171                                 'name': 'person_id_no_reset_sent',
172                                 'type': 'int'
173                             },
174                             {
175                                 'name': 'person_id_action_type',
176                                 'type': 'string'
177                             },
178                             {
179                                 'name': 'person_id_project_id',
180                                 'type': 'int'
181                             },
182                             {
183                                 'name': 'person_id_deleted_by',
184                                 'type': 'int'
185                             },
186                             {
187                                 'name': 'person_id_deleted_dt',
188                                 'type': 'date'
189                             }
190                         ]
191                     }
192                 },
193                 footer : {
194                     xtype: 'PagingToolbar',
195                     xns: Roo,
196                     pageSize : 25,
197                     displayInfo : true,
198                     displayMsg : "Displaying core_watch{0} - {1} of {2}",
199                     emptyMsg : "No core_watch found"
200                 },
201                 toolbar : {
202                     xtype: 'Toolbar',
203                     xns: Roo,
204                     items : [
205                         {
206                             xtype: 'TextItem',
207                             xns: Roo.Toolbar,
208                             text : "Show"
209                         },
210                         {
211                             xtype: 'ComboBox',
212                             xns: Roo.form,
213                             listeners : {
214                                 select : function (combo, record, index)
215                                 {
216                                   _this.grid.footer.onClick('first');
217                                 },
218                                 render : function (_self)
219                                 {
220                                   _this.affectSel = _self;
221                                 }
222                             },
223                             allowBlank : true,
224                             displayField : 'on_table',
225                             editable : false,
226                             emptyText : "Select Affects",
227                             forceSelection : true,
228                             listWidth : 300,
229                             loadingText : "Searching...",
230                             minChars : 2,
231                             name : 'on_table',
232                             pageSize : 20,
233                             qtip : "Select Action",
234                             queryParam : 'query[on_table]',
235                             selectOnFocus : true,
236                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{ontable}</b> </div>',
237                             triggerAction : 'all',
238                             typeAhead : true,
239                             valueField : 'action',
240                             width : 150,
241                             store : {
242                                 xtype: 'Store',
243                                 xns: Roo.data,
244                                 listeners : {
245                                     beforeload : function (_self, o)
246                                     {
247                                         o.params = o.params || {};
248                                         // staff can see all logs, other companies can only see their own.
249                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
250                                             o.params.company_id = Pman.Login.authUser.company_id;
251                                         }
252                                         o.params._distinct = 'on_table';
253                                         o.params._columns ='on_table';
254                                     }
255                                 },
256                                 remoteSort : true,
257                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
258                                 proxy : {
259                                     xtype: 'HttpProxy',
260                                     xns: Roo.data,
261                                     method : 'GET',
262                                     url : baseURL + '/Roo/Core_watch.php'
263                                 },
264                                 reader : {
265                                     xtype: 'JsonReader',
266                                     xns: Roo.data,
267                                     totalProperty : 'total',
268                                     root : 'data',
269                                     id : 'id',
270                                     fields : [
271                                         {
272                                             'name': 'id',
273                                             'type': 'int'
274                                         },
275                                         {
276                                             'name': 'person_name',
277                                             'type': 'string'
278                                         },
279                                         {
280                                             'name': 'event_when',
281                                             'type': 'date',
282                                             'dateFormat': 'Y-m-d'
283                                         },
284                                         {
285                                             'name': 'action',
286                                             'type': 'string'
287                                         },
288                                         {
289                                             'name': 'ipaddr',
290                                             'type': 'string'
291                                         },
292                                         {
293                                             'name': 'on_id',
294                                             'type': 'int'
295                                         },
296                                         {
297                                             'name': 'on_table',
298                                             'type': 'string'
299                                         },
300                                         {
301                                             'name': 'person_id',
302                                             'type': 'int'
303                                         },
304                                         {
305                                             'name': 'remarks',
306                                             'type': 'string'
307                                         },
308                                         {
309                                             'name': 'person_id_id',
310                                             'type': 'int'
311                                         },
312                                         {
313                                             'name': 'person_id_office_id',
314                                             'type': 'int'
315                                         },
316                                         {
317                                             'name': 'person_id_name',
318                                             'type': 'string'
319                                         },
320                                         {
321                                             'name': 'person_id_phone',
322                                             'type': 'string'
323                                         },
324                                         {
325                                             'name': 'person_id_fax',
326                                             'type': 'string'
327                                         },
328                                         {
329                                             'name': 'person_id_email',
330                                             'type': 'string'
331                                         },
332                                         {
333                                             'name': 'person_id_company_id',
334                                             'type': 'int'
335                                         },
336                                         {
337                                             'name': 'person_id_role',
338                                             'type': 'string'
339                                         },
340                                         {
341                                             'name': 'person_id_active',
342                                             'type': 'int'
343                                         },
344                                         {
345                                             'name': 'person_id_remarks',
346                                             'type': 'string'
347                                         },
348                                         {
349                                             'name': 'person_id_passwd',
350                                             'type': 'string'
351                                         },
352                                         {
353                                             'name': 'person_id_owner_id',
354                                             'type': 'int'
355                                         },
356                                         {
357                                             'name': 'person_id_lang',
358                                             'type': 'string'
359                                         },
360                                         {
361                                             'name': 'person_id_no_reset_sent',
362                                             'type': 'int'
363                                         },
364                                         {
365                                             'name': 'person_id_action_type',
366                                             'type': 'string'
367                                         },
368                                         {
369                                             'name': 'person_id_project_id',
370                                             'type': 'int'
371                                         },
372                                         {
373                                             'name': 'person_id_deleted_by',
374                                             'type': 'int'
375                                         },
376                                         {
377                                             'name': 'person_id_deleted_dt',
378                                             'type': 'date'
379                                         }
380                                     ]
381                                 }
382                             }
383                         },
384                         {
385                             xtype: 'Fill',
386                             xns: Roo.Toolbar
387                         },
388                         {
389                             xtype: 'Button',
390                             xns: Roo.Toolbar,
391                             text : "Add",
392                             cls : 'x-btn-text-icon',
393                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
394                             listeners : {
395                                 click : function()
396                                 {
397                                     if (!_this.dialog) return;
398                                     _this.dialog.show( { id : 0 } , function() {
399                                         _this.grid.footer.onClick('first');
400                                    }); 
401                                 }
402                             }
403                         },
404                         {
405                             xtype: 'Button',
406                             xns: Roo.Toolbar,
407                             text : "Edit",
408                             cls : 'x-btn-text-icon',
409                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
410                             listeners : {
411                                 click : function()
412                                 {
413                                     var s = _this.grid.getSelectionModel().getSelections();
414                                     if (!s.length || (s.length > 1))  {
415                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
416                                         return;
417                                     }
418                                     if (!_this.dialog) return;
419                                     _this.dialog.show(s[0].data, function() {
420                                         _this.grid.footer.onClick('first');
421                                     }); 
422                                     
423                                 }
424                             }
425                         },
426                         {
427                             xtype: 'Button',
428                             xns: Roo.Toolbar,
429                             text : "Delete",
430                             cls : 'x-btn-text-icon',
431                             icon : rootURL + '/Pman/templates/images/trash.gif',
432                             listeners : {
433                                 click : function()
434                                 {
435                                      Pman.genericDelete(_this, 'core_watch'); 
436                                 }
437                             }
438                         }
439                     ]
440                 },
441                 colModel : [
442                     {
443                         xtype: 'ColumnModel',
444                         xns: Roo.grid,
445                         dataIndex : 'event',
446                         header : 'Watch Event',
447                         width : 100,
448                         renderer : function(v) { return String.format('{0}', v); }
449                     },
450                     {
451                         xtype: 'ColumnModel',
452                         xns: Roo.grid,
453                         dataIndex : 'ontable',
454                         header : 'Watch Table',
455                         width : 150,
456                         renderer : function(v) { return String.format('{0}', v); }
457                     },
458                     {
459                         xtype: 'ColumnModel',
460                         xns: Roo.grid,
461                         dataIndex : 'onid',
462                         header : 'Watch ID',
463                         width : 75,
464                         renderer : function(v) { return String.format('{0}', v); }
465                     },
466                     {
467                         xtype: 'ColumnModel',
468                         xns: Roo.grid,
469                         dataIndex : 'person_id_name',
470                         header : 'Who get\'s notified',
471                         width : 150,
472                         renderer : function(v) { return String.format('{0}', v); }
473                     },
474                     {
475                         xtype: 'ColumnModel',
476                         xns: Roo.grid,
477                         dataIndex : 'medium',
478                         header : 'What happens',
479                         width : 200,
480                         renderer : function(v) { return String.format('{0}', v); }
481                     },
482                     {
483                         xtype: 'ColumnModel',
484                         xns: Roo.grid,
485                         header : 'Active',
486                         width : 75,
487                         dataIndex : 'active',
488                         renderer : function(v) { return String.format('{0}', v); }
489                     }
490                 ]
491             }
492         });
493         this.layout = this.panel.layout;
494
495     }
496 });