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: 'Button',
207                             xns: Roo.Toolbar,
208                             text : "Add",
209                             cls : 'x-btn-text-icon',
210                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
211                             listeners : {
212                                 click : function()
213                                 {
214                                     if (!_this.dialog) return;
215                                     _this.dialog.show( { id : 0 } , function() {
216                                         _this.grid.footer.onClick('first');
217                                    }); 
218                                 }
219                             }
220                         },
221                         {
222                             xtype: 'Button',
223                             xns: Roo.Toolbar,
224                             text : "Edit",
225                             cls : 'x-btn-text-icon',
226                             icon : Roo.rootURL + 'images/default/tree/leaf.gif',
227                             listeners : {
228                                 click : function()
229                                 {
230                                     var s = _this.grid.getSelectionModel().getSelections();
231                                     if (!s.length || (s.length > 1))  {
232                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
233                                         return;
234                                     }
235                                     if (!_this.dialog) return;
236                                     _this.dialog.show(s[0].data, function() {
237                                         _this.grid.footer.onClick('first');
238                                     }); 
239                                     
240                                 }
241                             }
242                         },
243                         {
244                             xtype: 'Button',
245                             xns: Roo.Toolbar,
246                             text : "Delete",
247                             cls : 'x-btn-text-icon',
248                             icon : rootURL + '/Pman/templates/images/trash.gif',
249                             listeners : {
250                                 click : function()
251                                 {
252                                      Pman.genericDelete(_this, 'core_watch'); 
253                                 }
254                             }
255                         },
256                         {
257                             xtype: 'TextItem',
258                             xns: Roo.Toolbar
259                         },
260                         {
261                             xtype: 'ComboBox',
262                             xns: Roo.form,
263                             listeners : {
264                                 select : function (combo, record, index)
265                                 {
266                                   _this.grid.footer.onClick('first');
267                                 },
268                                 render : function (_self)
269                                 {
270                                   _this.affectSel = _self;
271                                 }
272                             },
273                             allowBlank : true,
274                             displayField : 'on_table',
275                             editable : false,
276                             emptyText : "Select Affects",
277                             forceSelection : true,
278                             listWidth : 300,
279                             loadingText : "Searching...",
280                             minChars : 2,
281                             name : 'on_table',
282                             pageSize : 20,
283                             qtip : "Select Action",
284                             queryParam : 'query[on_table]',
285                             selectOnFocus : true,
286                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
287                             triggerAction : 'all',
288                             typeAhead : true,
289                             valueField : 'action',
290                             width : 150,
291                             store : {
292                                 xtype: 'Store',
293                                 xns: Roo.data,
294                                 listeners : {
295                                     beforeload : function (_self, o)
296                                     {
297                                         o.params = o.params || {};
298                                         // staff can see all logs, other companies can only see their own.
299                                         if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
300                                             o.params.company_id = Pman.Login.authUser.company_id;
301                                         }
302                                         o.params._distinct = 'on_table';
303                                         o.params._columns ='on_table';
304                                     }
305                                 },
306                                 remoteSort : true,
307                                 sortInfo : { field : 'on_table' , direction : 'ASC' },
308                                 proxy : {
309                                     xtype: 'HttpProxy',
310                                     xns: Roo.data,
311                                     method : 'GET',
312                                     url : baseURL + '/Roo/Core_watch.php'
313                                 },
314                                 reader : {
315                                     xtype: 'JsonReader',
316                                     xns: Roo.data,
317                                     totalProperty : 'total',
318                                     root : 'data',
319                                     id : 'id',
320                                     fields : [
321                                         {
322                                             'name': 'id',
323                                             'type': 'int'
324                                         },
325                                         {
326                                             'name': 'person_name',
327                                             'type': 'string'
328                                         },
329                                         {
330                                             'name': 'event_when',
331                                             'type': 'date',
332                                             'dateFormat': 'Y-m-d'
333                                         },
334                                         {
335                                             'name': 'action',
336                                             'type': 'string'
337                                         },
338                                         {
339                                             'name': 'ipaddr',
340                                             'type': 'string'
341                                         },
342                                         {
343                                             'name': 'on_id',
344                                             'type': 'int'
345                                         },
346                                         {
347                                             'name': 'on_table',
348                                             'type': 'string'
349                                         },
350                                         {
351                                             'name': 'person_id',
352                                             'type': 'int'
353                                         },
354                                         {
355                                             'name': 'remarks',
356                                             'type': 'string'
357                                         },
358                                         {
359                                             'name': 'person_id_id',
360                                             'type': 'int'
361                                         },
362                                         {
363                                             'name': 'person_id_office_id',
364                                             'type': 'int'
365                                         },
366                                         {
367                                             'name': 'person_id_name',
368                                             'type': 'string'
369                                         },
370                                         {
371                                             'name': 'person_id_phone',
372                                             'type': 'string'
373                                         },
374                                         {
375                                             'name': 'person_id_fax',
376                                             'type': 'string'
377                                         },
378                                         {
379                                             'name': 'person_id_email',
380                                             'type': 'string'
381                                         },
382                                         {
383                                             'name': 'person_id_company_id',
384                                             'type': 'int'
385                                         },
386                                         {
387                                             'name': 'person_id_role',
388                                             'type': 'string'
389                                         },
390                                         {
391                                             'name': 'person_id_active',
392                                             'type': 'int'
393                                         },
394                                         {
395                                             'name': 'person_id_remarks',
396                                             'type': 'string'
397                                         },
398                                         {
399                                             'name': 'person_id_passwd',
400                                             'type': 'string'
401                                         },
402                                         {
403                                             'name': 'person_id_owner_id',
404                                             'type': 'int'
405                                         },
406                                         {
407                                             'name': 'person_id_lang',
408                                             'type': 'string'
409                                         },
410                                         {
411                                             'name': 'person_id_no_reset_sent',
412                                             'type': 'int'
413                                         },
414                                         {
415                                             'name': 'person_id_action_type',
416                                             'type': 'string'
417                                         },
418                                         {
419                                             'name': 'person_id_project_id',
420                                             'type': 'int'
421                                         },
422                                         {
423                                             'name': 'person_id_deleted_by',
424                                             'type': 'int'
425                                         },
426                                         {
427                                             'name': 'person_id_deleted_dt',
428                                             'type': 'date'
429                                         }
430                                     ]
431                                 }
432                             }
433                         },
434                         {
435                             xtype: 'TextItem',
436                             xns: Roo.Toolbar
437                         }
438                     ]
439                 },
440                 colModel : [
441                     {
442                         xtype: 'ColumnModel',
443                         xns: Roo.grid,
444                         dataIndex : 'event',
445                         header : 'Watch Event',
446                         width : 100,
447                         renderer : function(v) { return String.format('{0}', v); }
448                     },
449                     {
450                         xtype: 'ColumnModel',
451                         xns: Roo.grid,
452                         dataIndex : 'ontable',
453                         header : 'Watch Table',
454                         width : 150,
455                         renderer : function(v) { return String.format('{0}', v); }
456                     },
457                     {
458                         xtype: 'ColumnModel',
459                         xns: Roo.grid,
460                         dataIndex : 'onid',
461                         header : 'Watch ID',
462                         width : 75,
463                         renderer : function(v) { return String.format('{0}', v); }
464                     },
465                     {
466                         xtype: 'ColumnModel',
467                         xns: Roo.grid,
468                         dataIndex : 'person_id_name',
469                         header : 'Who get\'s notified',
470                         width : 150,
471                         renderer : function(v) { return String.format('{0}', v); }
472                     },
473                     {
474                         xtype: 'ColumnModel',
475                         xns: Roo.grid,
476                         dataIndex : 'medium',
477                         header : 'What happens',
478                         width : 200,
479                         renderer : function(v) { return String.format('{0}', v); }
480                     },
481                     {
482                         xtype: 'ColumnModel',
483                         xns: Roo.grid,
484                         header : 'Active',
485                         width : 75,
486                         dataIndex : 'active',
487                         renderer : function(v) { return String.format('{0}', v); }
488                     }
489                 ]
490             }
491         });
492         this.layout = this.panel.layout;
493
494     }
495 });