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