Pman.Tab.AdminNotify.bjs
[Pman.Admin] / Pman.Tab.AdminNotify.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.AdminNotify = new Roo.XComponent({
6     part     :  ["Admin","Notify"],
7     order    : '001-Pman.Tab.AdminNotify',
8     region   : 'center',
9     parent   : 'Pman.Tab.AdminWatchNotify',
10     name     : "Pman.Tab.AdminNotify",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                     
27                 }
28             },
29             background : true,
30             fitContainer : true,
31             fitToframe : true,
32             region : 'center',
33             tableName : 'core_notify',
34             title : "Current Notifications",
35             grid : {
36                 xtype: 'Grid',
37                 xns: Roo.grid,
38                 listeners : {
39                     render : function() 
40                     {
41                         _this.grid = this; 
42                         //_this.dialog = Pman.Dialog.FILL_IN
43                         if (_this.panel.active) {
44                            this.footer.onClick('first');
45                         }
46                     },
47                     rowdblclick : function (_self, rowIndex, e)
48                     {
49                         if (!_this.dialog) return;
50                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
51                             _this.grid.footer.onClick('first');
52                         }); 
53                     }
54                 },
55                 autoExpandColumn : 'person_id_name',
56                 loadMask : true,
57                 dataSource : {
58                     xtype: 'Store',
59                     xns: Roo.data,
60                     listeners : {
61                         beforeload : function (_self, options)
62                         {
63                             if (!_this.toggleBtn.pressed) {
64                                 options.params['event_id'] = 0;
65                             }
66                             if (!_this.personCombo) {
67                                 return false;
68                             }
69                             var p = _this.personCombo.getValue();
70                             if (p*1) { 
71                                 options.params.person_id = p;
72                             }
73                             
74                         }
75                     },
76                     remoteSort : true,
77                     sortInfo : { field : 'act_when', direction: 'DESC' },
78                     proxy : {
79                         xtype: 'HttpProxy',
80                         xns: Roo.data,
81                         method : 'GET',
82                         url : baseURL + '/Roo/core_notify.php'
83                     },
84                     reader : {
85                         xtype: 'JsonReader',
86                         xns: Roo.data,
87                         totalProperty : 'total',
88                         root : 'data',
89                         id : 'id',
90                         fields : [
91                             {
92                                 'name': 'id',
93                                 'type': 'int'
94                             },
95                             {
96                                 'name': 'act_when',
97                                 'type': 'date',
98                                 'dateFormat': 'Y-m-d'
99                             },
100                             {
101                                 'name': 'onid',
102                                 'type': 'int'
103                             },
104                             {
105                                 'name': 'ontable',
106                                 'type': 'string'
107                             },
108                             {
109                                 'name': 'person_id',
110                                 'type': 'int'
111                             },
112                             {
113                                 'name': 'msgid',
114                                 'type': 'string'
115                             },
116                             {
117                                 'name': 'sent',
118                                 'type': 'date',
119                                 'dateFormat': 'Y-m-d'
120                             },
121                             {
122                                 'name': 'event_id',
123                                 'type': 'int'
124                             },
125                             {
126                                 'name': 'person_id_id',
127                                 'type': 'int'
128                             },
129                             {
130                                 'name': 'person_id_office_id',
131                                 'type': 'int'
132                             },
133                             {
134                                 'name': 'person_id_name',
135                                 'type': 'string'
136                             },
137                             {
138                                 'name': 'person_id_phone',
139                                 'type': 'string'
140                             },
141                             {
142                                 'name': 'person_id_fax',
143                                 'type': 'string'
144                             },
145                             {
146                                 'name': 'person_id_email',
147                                 'type': 'string'
148                             },
149                             {
150                                 'name': 'person_id_company_id',
151                                 'type': 'int'
152                             },
153                             {
154                                 'name': 'person_id_role',
155                                 'type': 'string'
156                             },
157                             {
158                                 'name': 'person_id_active',
159                                 'type': 'int'
160                             },
161                             {
162                                 'name': 'person_id_remarks',
163                                 'type': 'string'
164                             },
165                             {
166                                 'name': 'person_id_passwd',
167                                 'type': 'string'
168                             },
169                             {
170                                 'name': 'person_id_owner_id',
171                                 'type': 'int'
172                             },
173                             {
174                                 'name': 'person_id_lang',
175                                 'type': 'string'
176                             },
177                             {
178                                 'name': 'person_id_no_reset_sent',
179                                 'type': 'int'
180                             },
181                             {
182                                 'name': 'person_id_action_type',
183                                 'type': 'string'
184                             },
185                             {
186                                 'name': 'person_id_project_id',
187                                 'type': 'int'
188                             },
189                             {
190                                 'name': 'person_id_deleted_by',
191                                 'type': 'int'
192                             },
193                             {
194                                 'name': 'person_id_deleted_dt',
195                                 'type': 'date'
196                             },
197                             {
198                                 'name': 'event_id_id',
199                                 'type': 'int'
200                             },
201                             {
202                                 'name': 'event_id_person_name',
203                                 'type': 'string'
204                             },
205                             {
206                                 'name': 'event_id_event_when',
207                                 'type': 'date'
208                             },
209                             {
210                                 'name': 'event_id_action',
211                                 'type': 'string'
212                             },
213                             {
214                                 'name': 'event_id_ipaddr',
215                                 'type': 'string'
216                             },
217                             {
218                                 'name': 'event_id_on_id',
219                                 'type': 'int'
220                             },
221                             {
222                                 'name': 'event_id_on_table',
223                                 'type': 'string'
224                             },
225                             {
226                                 'name': 'event_id_person_id',
227                                 'type': 'int'
228                             },
229                             {
230                                 'name': 'event_id_remarks',
231                                 'type': 'string'
232                             }
233                         ]
234                     }
235                 },
236                 footer : {
237                     xtype: 'PagingToolbar',
238                     xns: Roo,
239                     pageSize : 25,
240                     displayInfo : true,
241                     displayMsg : "Displaying core_notify{0} - {1} of {2}",
242                     emptyMsg : "No core_notify found"
243                 },
244                 toolbar : {
245                     xtype: 'Toolbar',
246                     xns: Roo,
247                     items : [
248                         {
249                             xtype: 'ComboBox',
250                             xns: Roo.form,
251                             listeners : {
252                                 select : function (combo, record, index)
253                                 {
254                                    (function() { _this.grid.footer.onClick('first'); }).defer(100);
255                                 },
256                                 render : function (_self)
257                                 {
258                                    _this.personCombo = _self;
259                                 }
260                             },
261                             allowBlank : true,
262                             displayField : 'person_id_name',
263                             editable : true,
264                             emptyText : "Select person",
265                             forceSelection : true,
266                             hiddenName : 'id',
267                             listWidth : 400,
268                             loadingText : "Searching...",
269                             minChars : 2,
270                             name : 'name',
271                             pageSize : 20,
272                             qtip : "Select core_notify",
273                             queryParam : 'query[person_id_name]',
274                             selectOnFocus : true,
275                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{person_id_name}</b> {person_id_email}</div>',
276                             triggerAction : 'all',
277                             valueField : 'person_id',
278                             width : 300,
279                             store : {
280                                 xtype: 'Store',
281                                 xns: Roo.data,
282                                 listeners : {
283                                     beforeload : function (_self, o){
284                                         o.params = o.params || {};
285                                         o.params._distinct='person_id';
286                                         o.params._columns='person_id,person_id_name,person_id_email';
287                                         o.params['!person_id_name'] = '';
288                                         
289                                         // set more here
290                                     }
291                                 },
292                                 remoteSort : true,
293                                 sortInfo : { direction : 'ASC', field: 'person_id_name' },
294                                 proxy : {
295                                     xtype: 'HttpProxy',
296                                     xns: Roo.data,
297                                     method : 'GET',
298                                     url : baseURL + '/Roo/core_notify.php'
299                                 },
300                                 reader : {
301                                     xtype: 'JsonReader',
302                                     xns: Roo.data,
303                                     id : 'id',
304                                     root : 'data',
305                                     totalProperty : 'total',
306                                     fields : [{"name":"id","type":"int"},{"name":"ontable","type":"string"}]
307                                 }
308                             }
309                         },
310                         {
311                             xtype: 'Fill',
312                             xns: Roo.Toolbar
313                         },
314                         {
315                             xtype: 'Button',
316                             xns: Roo.Toolbar,
317                             listeners : {
318                                 click : function()
319                                         {
320                                         Pman.genericDelete(_this, 'core_notify'); 
321                                         }
322                             },
323                             cls : 'x-btn-text-icon',
324                             text : "Delete",
325                             icon : rootURL + '/Pman/templates/images/trash.gif'
326                         },
327                         {
328                             xtype: 'Button',
329                             xns: Roo.Toolbar,
330                             listeners : {
331                                 render : function (_self)
332                                 {
333                                     _this.toggleBtn = _self;
334                                 },
335                                 toggle : function (_self, pressed)
336                                 {
337                                     this.setText(pressed ? "Hide Completed" : "Show Completed");
338                                     _this.grid.footer.onClick('first');
339                                 }
340                             },
341                             enableToggle : true,
342                             text : "Show Completed"
343                         }
344                     ]
345                 },
346                 colModel : [
347                     {
348                         xtype: 'ColumnModel',
349                         xns: Roo.grid,
350                         dataIndex : 'id',
351                         header : 'id#',
352                         sortable : true,
353                         width : 50,
354                         renderer : function(v) { return String.format('{0}', v ); }
355                     },
356                     {
357                         xtype: 'ColumnModel',
358                         xns: Roo.grid,
359                         dataIndex : 'evtype',
360                         header : 'Method',
361                         sortable : true,
362                         width : 100,
363                         renderer : function(v) { return String.format('{0}', v ); }
364                     },
365                     {
366                         xtype: 'ColumnModel',
367                         xns: Roo.grid,
368                         dataIndex : 'act_when',
369                         header : 'Act when',
370                         sortable : true,
371                         width : 100,
372                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }
373                     },
374                     {
375                         xtype: 'ColumnModel',
376                         xns: Roo.grid,
377                         dataIndex : 'sent',
378                         header : 'Sent',
379                         sortable : true,
380                         width : 100,
381                         renderer : function(v,x,r) {
382                             if (r.data.event_id *1 == 0) {
383                                 return '';
384                             }
385                              return String.format('{0}', v ? v.format('d/M/Y H:i:s') : '');
386                           }
387                     },
388                     {
389                         xtype: 'ColumnModel',
390                         xns: Roo.grid,
391                         dataIndex : 'ontable',
392                         header : 'Ontable',
393                         width : 100,
394                         renderer : function(v,x,r) { return String.format('{0}:{1}', v,r.data.onid); }
395                     },
396                     {
397                         xtype: 'ColumnModel',
398                         xns: Roo.grid,
399                         dataIndex : 'person_id_name',
400                         header : 'Who to notify',
401                         width : 100,
402                         renderer : function(v,x,r) {
403                              return String.format('{0} <u>&lt;{1}&gt;</u>', v, r.data.person_id_email); 
404                          }
405                     },
406                     {
407                         xtype: 'ColumnModel',
408                         xns: Roo.grid,
409                         dataIndex : 'trigger_event_id',
410                         header : 'Triggered by',
411                         width : 100,
412                         renderer : function(v,x,r) {
413                              return String.format(
414                                     '{0} : {1} {2}', 
415                                     r.data.trigger_event_id_on_table, 
416                                     r.data.trigger_event_id_on_id, 
417                                     r.data.trigger_event_id_remarks
418                                 ); 
419                          }
420                     },
421                     {
422                         xtype: 'ColumnModel',
423                         xns: Roo.grid,
424                         header : 'Msgid',
425                         width : 200,
426                         dataIndex : 'msgid',
427                         renderer : function(v) { return String.format('{0}', v); }
428                     },
429                     {
430                         xtype: 'ColumnModel',
431                         xns: Roo.grid,
432                         dataIndex : 'event_id_remarks',
433                         header : 'Event',
434                         width : 300,
435                         renderer : function(v) { return String.format('<span qtip="{0}">{0}</span>', v); }
436                     }
437                 ]
438             }
439         };
440     }
441 });