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