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