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                                var from = _this.fromDateSel.getValue();
205                                
206                                if(from){
207                                    options.params.from = from.format('Y-m-d');
208                                }
209                                
210                                var to = _this.toDateSel.getValue();
211                                
212                                if(to){
213                                    options.params.to = to.format('Y-m-d');
214                                }
215                            }
216                     },
217                     items : [
218
219                     ]
220
221                 },
222                 footer : {
223                     '|xns' : 'Roo',
224                     pageSize : 25,
225                     xtype : 'PagingToolbar',
226                     emptyMsg : "No core_notify found",
227                     xns : Roo,
228                     displayInfo : true,
229                     displayMsg : "Displaying core_notify{0} - {1} of {2}"
230                 },
231                 toolbar : {
232                     '|xns' : 'Roo',
233                     xtype : 'Toolbar',
234                     xns : Roo,
235                     items : [
236                         {
237                             store : {
238                                 proxy : {
239                                     '|xns' : 'Roo.data',
240                                     url : baseURL + '/Roo/core_notify.php',
241                                     method : 'GET',
242                                     xtype : 'HttpProxy',
243                                     xns : Roo.data
244                                 },
245                                 reader : {
246                                     '|xns' : 'Roo.data',
247                                     id : 'id',
248                                     root : 'data',
249                                     xtype : 'JsonReader',
250                                     xns : Roo.data,
251                                     fields : [{"name":"id","type":"int"},{"name":"ontable","type":"string"}],
252                                     totalProperty : 'total'
253                                 },
254                                 '|xns' : 'Roo.data',
255                                 xtype : 'Store',
256                                 remoteSort : true,
257                                 sortInfo : { direction : 'ASC', field: 'person_id_name' },
258                                 xns : Roo.data,
259                                 listeners : {
260                                         beforeload : function (_self, o){
261                                                o.params = o.params || {};
262                                                o.params._distinct='person_id';
263                                                o.params._columns='person_id,person_id_name,person_id_email';
264                                                o.params['!person_id_name'] = '';
265                                                
266                                                // set more here
267                                            }
268                                 },
269                                 items : [
270
271                                 ]
272
273                             },
274                             '|xns' : 'Roo.form',
275                             listWidth : 400,
276                             triggerAction : 'all',
277                             forceSelection : true,
278                             selectOnFocus : true,
279                             pageSize : 20,
280                             displayField : 'person_id_name',
281                             emptyText : "Select person",
282                             hiddenName : 'id',
283                             minChars : 2,
284                             valueField : 'person_id',
285                             xtype : 'ComboBox',
286                             allowBlank : true,
287                             editable : true,
288                             width : 200,
289                             xns : Roo.form,
290                             name : 'name',
291                             qtip : "Select core_notify",
292                             queryParam : 'query[person_id_name]',
293                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{person_id_name}</b> {person_id_email}</div>',
294                             loadingText : "Searching...",
295                             listeners : {
296                                 render : function (_self)
297                                    {
298                                       _this.personCombo = _self;
299                                    },
300                                 select : function (combo, record, index)
301                                    {
302                                       _this.grid.footer.onClick('first');
303                                    }
304                             },
305                             items : [
306
307                             ]
308
309                         },
310                         {
311                             '|xns' : 'Roo.Toolbar',
312                             xtype : 'Separator',
313                             xns : Roo.Toolbar
314                         },
315                         {
316                             '|xns' : 'Roo.Toolbar',
317                             text : "From",
318                             xtype : 'TextItem',
319                             xns : Roo.Toolbar
320                         },
321                         {
322                             '|xns' : 'Roo.form',
323                             format : 'd/M/Y',
324                             xtype : 'DateField',
325                             width : 100,
326                             xns : Roo.form,
327                             listeners : {
328                                 render : function (_self)\r
329                                    {\r
330                                        _this.fromDateSel = _self;\r
331                                       //_self.setValue(  new Date() );\r
332                                    },
333                                 select : function (combo, date)
334                                    {
335                                        _this.grid.footer.onClick('first');
336                                    }
337                             }
338                         },
339                         {
340                             '|xns' : 'Roo.Toolbar',
341                             xtype : 'Separator',
342                             xns : Roo.Toolbar
343                         },
344                         {
345                             '|xns' : 'Roo.Toolbar',
346                             text : "To",
347                             xtype : 'TextItem',
348                             xns : Roo.Toolbar
349                         },
350                         {
351                             '|xns' : 'Roo.form',
352                             format : 'd/M/Y',
353                             xtype : 'DateField',
354                             width : 100,
355                             xns : Roo.form,
356                             listeners : {
357                                 render : function (_self)\r
358                                    {\r
359                                        _this.toDateSel = _self;\r
360                                       //_self.setValue(  new Date() );\r
361                                    },
362                                 select : function (combo, date)
363                                    {
364                                        _this.grid.footer.onClick('first');
365                                    }
366                             }
367                         },
368                         {
369                             '|xns' : 'Roo.Toolbar',
370                             xtype : 'Separator',
371                             xns : Roo.Toolbar
372                         },
373                         {
374                             '|xns' : 'Roo.Toolbar',
375                             xtype : 'Fill',
376                             xns : Roo.Toolbar
377                         },
378                         {
379                             '|xns' : 'Roo.Toolbar',
380                             text : "Delete",
381                             xtype : 'Button',
382                             cls : 'x-btn-text-icon',
383                             icon : rootURL + '/Pman/templates/images/trash.gif',
384                             xns : Roo.Toolbar,
385                             listeners : {
386                                 click : function()
387                                    {
388                                        Pman.genericDelete(_this, 'core_notify'); 
389                                    }
390                             }
391                         },
392                         {
393                             '|xns' : 'Roo.Toolbar',
394                             text : "Show Completed",
395                             enableToggle : true,
396                             xtype : 'Button',
397                             xns : Roo.Toolbar,
398                             listeners : {
399                                 toggle : function (_self, pressed)
400                                    {
401                                        this.setText(pressed ? "Hide Completed" : "Show Completed");
402                                        _this.grid.footer.onClick('first');
403                                    },
404                                 render : function (_self)
405                                    {
406                                        _this.toggleBtn = _self;
407                                    }
408                             }
409                         }
410                     ]
411
412                 },
413                 '|xns' : 'Roo.grid',
414                 autoExpandColumn : 'person_id_name',
415                 xtype : 'Grid',
416                 loadMask : true,
417                 xns : Roo.grid,
418                 colModel : [
419                          {
420                                 '|xns' : 'Roo.grid',
421                                 xtype : 'ColumnModel',
422                                 sortable : true,
423                                 header : 'id#',
424                                 width : 50,
425                                 renderer : function(v) { return String.format('{0}', v ); },
426                                 xns : Roo.grid,
427                                 dataIndex : 'id'
428                             },
429 {
430                                 '|xns' : 'Roo.grid',
431                                 xtype : 'ColumnModel',
432                                 sortable : true,
433                                 header : 'Method',
434                                 width : 200,
435                                 renderer : function(v,x,r) 
436                                 { 
437                                     var vv = (typeof(r.data.evtype_align) != 'undefined' && r.data.evtype_align) ? r.data.evtype_align : v;
438                                     return String.format('<span qtip="{0}">{1}</span>', v, vv ); 
439                                 },
440                                 xns : Roo.grid,
441                                 dataIndex : 'evtype'
442                             },
443 {
444                                 '|xns' : 'Roo.grid',
445                                 xtype : 'ColumnModel',
446                                 sortable : true,
447                                 header : 'Act when',
448                                 width : 150,
449                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
450                                 xns : Roo.grid,
451                                 dataIndex : 'act_when'
452                             },
453 {
454                                 '|xns' : 'Roo.grid',
455                                 xtype : 'ColumnModel',
456                                 sortable : true,
457                                 header : 'Sent',
458                                 width : 150,
459                                 renderer : function(v,x,r) {
460                                     if (r.data.event_id *1 == 0) {
461                                         return '';
462                                     }
463                                      return String.format('{0}', v ? v.format('d/M/Y H:i:s') : '');
464                                   },
465                                 xns : Roo.grid,
466                                 dataIndex : 'sent'
467                             },
468 {
469                                 '|xns' : 'Roo.grid',
470                                 xtype : 'ColumnModel',
471                                 header : 'Ontable',
472                                 width : 150,
473                                 renderer : function(v,x,r) { return String.format('{0}:{1}', v,r.data.onid); },
474                                 xns : Roo.grid,
475                                 dataIndex : 'ontable'
476                             },
477 {
478                                 '|xns' : 'Roo.grid',
479                                 xtype : 'ColumnModel',
480                                 header : 'Who to notify',
481                                 width : 100,
482                                 renderer : function(v,x,r) {
483                                      return String.format('{0} <u>&lt;{1}&gt;</u>', v, r.data.person_id_email); 
484                                  },
485                                 xns : Roo.grid,
486                                 dataIndex : 'person_id_name'
487                             },
488 {
489                                 '|xns' : 'Roo.grid',
490                                 xtype : 'ColumnModel',
491                                 header : 'Triggered by',
492                                 width : 100,
493                                 renderer : function(v,x,r) {
494                                      return String.format(
495                                             '{0} : {1} {2}', 
496                                             r.data.trigger_event_id_on_table, 
497                                             r.data.trigger_event_id_on_id, 
498                                             r.data.trigger_event_id_remarks
499                                         ); 
500                                  },
501                                 xns : Roo.grid,
502                                 dataIndex : 'trigger_event_id'
503                             },
504 {
505                                 '|xns' : 'Roo.grid',
506                                 xtype : 'ColumnModel',
507                                 width : 200,
508                                 header : 'Msgid',
509                                 renderer : function(v) { return String.format('{0}', v); },
510                                 xns : Roo.grid,
511                                 dataIndex : 'msgid'
512                             },
513 {
514                                 '|xns' : 'Roo.grid',
515                                 xtype : 'ColumnModel',
516                                 header : 'Event',
517                                 width : 300,
518                                 renderer : function(v) { return String.format('<span qtip="{0}">{0}</span>', v); },
519                                 xns : Roo.grid,
520                                 dataIndex : 'event_id_remarks'
521                             }
522                 ],
523                 listeners : {
524                         render : function() 
525                            {
526                                _this.grid = this; 
527                                //_this.dialog = Pman.Dialog.FILL_IN
528                                if (_this.panel.active) {
529                                   this.footer.onClick('first');
530                                }
531                            }
532                 },
533                 items : [
534
535                 ]
536
537             },
538             '|xns' : 'Roo',
539             fitToframe : true,
540             background : true,
541             region : 'center',
542             title : "Current Notifications",
543             xtype : 'GridPanel',
544             fitContainer : true,
545             xns : Roo,
546             tableName : 'core_notify',
547             listeners : {
548                 activate : function() {
549                        _this.panel = this;
550                        if (_this.grid) {
551                            _this.grid.footer.onClick('first');
552                        }
553                        
554                    }
555             },
556             items : [
557
558             ]
559
560         };    }
561 });