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