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 : 300,
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 : 'Fill',
371                             xns : Roo.Toolbar
372                         },
373                         {
374                             '|xns' : 'Roo.Toolbar',
375                             text : "Delete",
376                             xtype : 'Button',
377                             cls : 'x-btn-text-icon',
378                             icon : rootURL + '/Pman/templates/images/trash.gif',
379                             xns : Roo.Toolbar,
380                             listeners : {
381                                 click : function()
382                                    {
383                                        Pman.genericDelete(_this, 'core_notify'); 
384                                    }
385                             }
386                         },
387                         {
388                             '|xns' : 'Roo.Toolbar',
389                             text : "Show Completed",
390                             enableToggle : true,
391                             xtype : 'Button',
392                             xns : Roo.Toolbar,
393                             listeners : {
394                                 toggle : function (_self, pressed)
395                                    {
396                                        this.setText(pressed ? "Hide Completed" : "Show Completed");
397                                        _this.grid.footer.onClick('first');
398                                    },
399                                 render : function (_self)
400                                    {
401                                        _this.toggleBtn = _self;
402                                    }
403                             }
404                         }
405                     ]
406
407                 },
408                 '|xns' : 'Roo.grid',
409                 autoExpandColumn : 'person_id_name',
410                 xtype : 'Grid',
411                 loadMask : true,
412                 xns : Roo.grid,
413                 colModel : [
414                          {
415                                 '|xns' : 'Roo.grid',
416                                 xtype : 'ColumnModel',
417                                 sortable : true,
418                                 header : 'id#',
419                                 width : 50,
420                                 renderer : function(v) { return String.format('{0}', v ); },
421                                 xns : Roo.grid,
422                                 dataIndex : 'id'
423                             },
424 {
425                                 '|xns' : 'Roo.grid',
426                                 xtype : 'ColumnModel',
427                                 sortable : true,
428                                 header : 'Method',
429                                 width : 200,
430                                 renderer : function(v,x,r) 
431                                 { 
432                                     var vv = (typeof(r.data.evtype_align) != 'undefined' && r.data.evtype_align) ? r.data.evtype_align : v;
433                                     return String.format('<span qtip="{0}">{1}</span>', v, vv ); 
434                                 },
435                                 xns : Roo.grid,
436                                 dataIndex : 'evtype'
437                             },
438 {
439                                 '|xns' : 'Roo.grid',
440                                 xtype : 'ColumnModel',
441                                 sortable : true,
442                                 header : 'Act when',
443                                 width : 150,
444                                 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
445                                 xns : Roo.grid,
446                                 dataIndex : 'act_when'
447                             },
448 {
449                                 '|xns' : 'Roo.grid',
450                                 xtype : 'ColumnModel',
451                                 sortable : true,
452                                 header : 'Sent',
453                                 width : 150,
454                                 renderer : function(v,x,r) {
455                                     if (r.data.event_id *1 == 0) {
456                                         return '';
457                                     }
458                                      return String.format('{0}', v ? v.format('d/M/Y H:i:s') : '');
459                                   },
460                                 xns : Roo.grid,
461                                 dataIndex : 'sent'
462                             },
463 {
464                                 '|xns' : 'Roo.grid',
465                                 xtype : 'ColumnModel',
466                                 header : 'Ontable',
467                                 width : 150,
468                                 renderer : function(v,x,r) { return String.format('{0}:{1}', v,r.data.onid); },
469                                 xns : Roo.grid,
470                                 dataIndex : 'ontable'
471                             },
472 {
473                                 '|xns' : 'Roo.grid',
474                                 xtype : 'ColumnModel',
475                                 header : 'Who to notify',
476                                 width : 100,
477                                 renderer : function(v,x,r) {
478                                      return String.format('{0} <u>&lt;{1}&gt;</u>', v, r.data.person_id_email); 
479                                  },
480                                 xns : Roo.grid,
481                                 dataIndex : 'person_id_name'
482                             },
483 {
484                                 '|xns' : 'Roo.grid',
485                                 xtype : 'ColumnModel',
486                                 header : 'Triggered by',
487                                 width : 100,
488                                 renderer : function(v,x,r) {
489                                      return String.format(
490                                             '{0} : {1} {2}', 
491                                             r.data.trigger_event_id_on_table, 
492                                             r.data.trigger_event_id_on_id, 
493                                             r.data.trigger_event_id_remarks
494                                         ); 
495                                  },
496                                 xns : Roo.grid,
497                                 dataIndex : 'trigger_event_id'
498                             },
499 {
500                                 '|xns' : 'Roo.grid',
501                                 xtype : 'ColumnModel',
502                                 width : 200,
503                                 header : 'Msgid',
504                                 renderer : function(v) { return String.format('{0}', v); },
505                                 xns : Roo.grid,
506                                 dataIndex : 'msgid'
507                             },
508 {
509                                 '|xns' : 'Roo.grid',
510                                 xtype : 'ColumnModel',
511                                 header : 'Event',
512                                 width : 300,
513                                 renderer : function(v) { return String.format('<span qtip="{0}">{0}</span>', v); },
514                                 xns : Roo.grid,
515                                 dataIndex : 'event_id_remarks'
516                             }
517                 ],
518                 listeners : {
519                         render : function() 
520                            {
521                                _this.grid = this; 
522                                //_this.dialog = Pman.Dialog.FILL_IN
523                                if (_this.panel.active) {
524                                   this.footer.onClick('first');
525                                }
526                            }
527                 },
528                 items : [
529
530                 ]
531
532             },
533             '|xns' : 'Roo',
534             fitToframe : true,
535             background : true,
536             region : 'center',
537             title : "Current Notifications",
538             xtype : 'GridPanel',
539             fitContainer : true,
540             xns : Roo,
541             tableName : 'core_notify',
542             listeners : {
543                 activate : function() {
544                        _this.panel = this;
545                        if (_this.grid) {
546                            _this.grid.footer.onClick('first');
547                        }
548                        
549                    }
550             },
551             items : [
552
553             ]
554
555         };    }
556 });