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