init
[Pman.Admin] / Pman.Tab.AdminLogEvents.js
1 //<script type="text/javascript"> 
2        
3 // Auto generated file build Builder
4
5             
6        
7 // register the module first       
8 Pman.on('beforeload', function()
9 {
10
11     Pman.register({
12         modKey : '000-pman_tab_adminlogevents',
13         module : Pman.Tab.AdminLogEvents,
14         region : 'center',
15         parent : Pman.Tab.AdminLogs,
16         name : "Admin - Logs - Events"
17     });
18 });
19
20 Pman.Tab.AdminLogEvents = {
21     
22     panel : false,
23     disabled : false,
24     parentLayout:  false,
25
26     add : function(parentLayout, region)
27     {
28         
29         if (this.disabled) {
30             return;
31         }
32         var _this = this;
33         this.parentLayout = parentLayout;
34         
35         this.panel = this.parentLayout.addxtype({
36             xtype : 'GridPanel',
37             title : "Events",
38             fitToframe : true,
39             fitContainer : true,
40             tableName : 'Events',
41             background : true,
42             listeners : {
43                 activate: function() {
44                     _this.panel = this;
45                     if (_this.grid) {
46                         _this.grid.footer.onClick('first');
47                     }
48                 }
49             },
50             grid : {
51                 xtype : 'Grid',
52                 autoExpandColumn : 'remarks',
53                 loadMask : true,
54                 listeners : {
55                     render: function() { 
56                         _this.grid = this; 
57                         //_this.dialog = Pman.Dialog.FILL_IN
58                         if (_this.panel.active) {
59                            this.footer.onClick('first');
60                         }
61                     }
62                 },
63                 dataSource : {
64                     xtype : 'Store',
65                     reader: Pman.Readers.Events,
66                     listeners : {
67                         beforeload: function (_self, o)
68                         {
69                            if (! _this.personSel) {
70                             return;
71                             }
72                             o.params = o.params || {};
73                             o.params.person_id = _this.personSel.getValue();
74                             
75                         }
76                     },
77                     remoteSort : true,
78                     sortInfo: { field: 'event_when', direction: 'DESC'},
79                     proxy : {
80                         xtype : 'HttpProxy',
81                         method : 'GET',
82                         url: baseURL + '/Roo/Events.php'
83                     }
84                 },
85                 colModel : [
86                     {
87                         header : 'When',
88                         width : 100,
89                         dataIndex : 'event_when',
90                         renderer: function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; }
91                     },
92                     {
93                         header : 'Staff',
94                         width : 150,
95                         dataIndex : 'person_name',
96                         renderer: function(v) { return String.format('{0}', v); }
97                     },
98                     {
99                         header : 'Action',
100                         width : 100,
101                         dataIndex : 'action',
102                         renderer: function(v) { return String.format('{0}', v); }
103                     },
104                     {
105                         header : 'IP',
106                         width : 100,
107                         dataIndex : 'ipaddr',
108                         renderer: function(v) { return String.format('{0}', v); }
109                     },
110                     {
111                         header : 'Affected',
112                         width : 100,
113                         dataIndex : 'on_id',
114                         renderer: function(v, x, r) {                             return v ? String.format('{0}({1})', r.data.on_table, v)  : '';                         }
115                     },
116                     {
117                         header : 'Remarks',
118                         width : 300,
119                         dataIndex : 'remarks',
120                         renderer: function(v) { return String.format('{0}', v); }
121                     }
122                 ],
123                 footer : {
124                     xtype : 'PagingToolbar',
125                     pageSize : 25,
126                     displayInfo : true,
127                     displayMsg : "Displaying Events  {0} - {1} of {2}",
128                     emptyMsg : "No Events found"
129                 },
130                 toolbar : {
131                     xtype : 'Toolbar',
132                     items : [
133                         {
134                             xtype : 'TextItem',
135                             xns: Roo.Toolbar,
136                             text : "Show"
137                         },
138                         {
139                             fieldLabel : "Person ",
140                             name : 'person_id_name',
141                             qtip : "Select Person ",
142                             emptyText : "Select Person ",
143                             xtype : 'ComboBox',
144                             selectOnFocus : true,
145                             allowBlank : true,
146                             width : 150,
147                             listWidth : 400,
148                             editable : false,
149                             displayField : 'name',
150                             valueField : 'id',
151                             typeAhead : true,
152                             forceSelection : true,
153                             triggerAction : 'all',
154                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}<\/b> <\/div>',
155                             queryParam : 'query[name]',
156                             loadingText : "Searching...",
157                             minChars : 2,
158                             pageSize : 20,
159                             listeners : {
160                                 select: function (combo, record, index)
161                                 {
162                                   _this.grid.footer.onClick('first');
163                                 },
164                                 render: function (_self)
165                                 {
166                                   _this.personSel = _self;
167                                 }
168                             },
169                             store : {
170                                 xtype : 'Store',
171                                 reader: Pman.Readers.Person,
172                                 listeners : {
173                                     beforeload: function (_self, o)
174                                     {
175                                         o.params = o.params || {};
176                                         o.company_id = Pman.Login.authUser.company_id;
177                                     }
178                                 },
179                                 proxy : {
180                                     xtype : 'HttpProxy',
181                                     url: baseURL + '/Roo/Person.php',
182                                     method : 'GET'
183                                 }
184                             }
185                         }
186                     ]
187                 }
188             },
189             region : 'center'
190         });
191
192         
193         
194     }
195 }