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