Pman.Tab.AdminLogEvents.bjs
[Pman.Admin] / Pman.Tab.AdminLogEvents.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.AdminLogEvents = new Roo.XComponent({
8     part     :  ["Admin", "LogEvents" ],
9     order    : '001-Pman.Tab.AdminLogEvents',
10     region   : 'center',
11     parent   : 'Pman.Tab.AdminLogs',
12     name     : "Admin - Logs - Events",
13     disabled : false, 
14     permname : 'Admin.Logs', 
15     _tree : function()
16     {
17         var _this = this;
18         var MODULE = this;
19         return {
20             layout : {
21                 center : {
22                     '|xns' : 'Roo',
23                     xtype : 'LayoutRegion',
24                     xns : Roo
25                 },
26                 south : {
27                     '|xns' : 'Roo',
28                     autoScroll : true,
29                     xtype : 'LayoutRegion',
30                     xns : Roo,
31                     split : true,
32                     height : 150
33                 },
34                 '|xns' : 'Roo',
35                 xtype : 'BorderLayout',
36                 xns : Roo,
37                 items : [
38                         {
39                         '|xns' : 'Roo',
40                         fitToFrame : true,
41                         region : 'south',
42                         xtype : 'ContentPanel',
43                         xns : Roo,
44                         listeners : {
45                                 render : function (_self)
46                                    {
47                                      _this.viewPanel = _self;
48                                    }
49                         }
50                     },
51                         {
52                         grid : {
53                             sm : {
54                                 '|xns' : 'Roo.grid',
55                                 xtype : 'RowSelectionModel',
56                                 singleSelect : true,
57                                 xns : Roo.grid,
58                                 listeners : {
59                                         afterselectionchange : function (_self)
60                                            {
61                                                // load detail log in _this.viewPanel;
62                                                if (!this.getSelected()) {
63                                                    this.viewPanel.setContent("Nothing Selected");
64                                                    return;
65                                                }
66                                                var id = this.getSelected().data.id;
67                                                _this.viewPanel.load( { url : baseURL + "/Admin/EventView/" + id + ".html" });
68                                                
69                                            }
70                                 }
71                             },
72                             dataSource : {
73                                 reader : {
74                                     '|xns' : 'Roo.data',
75                                     id : 'id',
76                                     root : 'data',
77                                     xtype : 'JsonReader',
78                                     xns : Roo.data,
79                                     fields : [
80                                         {
81                                             'name': 'id',
82                                             'type': 'int'
83                                         },
84                                         {
85                                             'name': 'person_name',
86                                             'type': 'string'
87                                         },
88                                         {
89                                             'name': 'event_when',
90                                             'type': 'date',
91                                             'dateFormat': 'Y-m-d'
92                                         },
93                                         {
94                                             'name': 'action',
95                                             'type': 'string'
96                                         },
97                                         {
98                                             'name': 'ipaddr',
99                                             'type': 'string'
100                                         },
101                                         {
102                                             'name': 'on_id',
103                                             'type': 'int'
104                                         },
105                                         {
106                                             'name': 'on_table',
107                                             'type': 'string'
108                                         },
109                                         {
110                                             'name': 'person_id',
111                                             'type': 'int'
112                                         },
113                                         {
114                                             'name': 'remarks',
115                                             'type': 'string'
116                                         },
117                                         {
118                                             'name': 'person_id_id',
119                                             'type': 'int'
120                                         },
121                                         {
122                                             'name': 'person_id_office_id',
123                                             'type': 'int'
124                                         },
125                                         {
126                                             'name': 'person_id_name',
127                                             'type': 'string'
128                                         },
129                                         {
130                                             'name': 'person_id_phone',
131                                             'type': 'string'
132                                         },
133                                         {
134                                             'name': 'person_id_fax',
135                                             'type': 'string'
136                                         },
137                                         {
138                                             'name': 'person_id_email',
139                                             'type': 'string'
140                                         },
141                                         {
142                                             'name': 'person_id_company_id',
143                                             'type': 'int'
144                                         },
145                                         {
146                                             'name': 'person_id_role',
147                                             'type': 'string'
148                                         },
149                                         {
150                                             'name': 'person_id_active',
151                                             'type': 'int'
152                                         },
153                                         {
154                                             'name': 'person_id_remarks',
155                                             'type': 'string'
156                                         },
157                                         {
158                                             'name': 'person_id_passwd',
159                                             'type': 'string'
160                                         },
161                                         {
162                                             'name': 'person_id_owner_id',
163                                             'type': 'int'
164                                         },
165                                         {
166                                             'name': 'person_id_lang',
167                                             'type': 'string'
168                                         },
169                                         {
170                                             'name': 'person_id_no_reset_sent',
171                                             'type': 'int'
172                                         },
173                                         {
174                                             'name': 'person_id_action_type',
175                                             'type': 'string'
176                                         },
177                                         {
178                                             'name': 'person_id_project_id',
179                                             'type': 'int'
180                                         },
181                                         {
182                                             'name': 'person_id_deleted_by',
183                                             'type': 'int'
184                                         },
185                                         {
186                                             'name': 'person_id_deleted_dt',
187                                             'type': 'date'
188                                         }
189                                     ],
190                                     totalProperty : 'total'
191                                 },
192                                 proxy : {
193                                     '|xns' : 'Roo.data',
194                                     url : baseURL + '/Roo/Events.php',
195                                     method : 'GET',
196                                     xtype : 'HttpProxy',
197                                     xns : Roo.data
198                                 },
199                                 '|xns' : 'Roo.data',
200                                 xtype : 'Store',
201                                 remoteSort : true,
202                                 sortInfo : { field: 'event_when', direction: 'DESC'},
203                                 xns : Roo.data,
204                                 listeners : {
205                                         beforeload : function (_self, o)
206                                            {
207                                                if (!Pman.buildCompleted) {
208                                                    return false;
209                                                }
210                                               
211                                               
212                                               if (! _this.personSel) {
213                                                return false;
214                                                }
215                                                o.params = o.params || {};
216                                                o.params.person_id = _this.personSel.getValue();
217                                                var act = _this.actionSel.getValue();
218                                                if (act.length) {
219                                                    o.params.action = act;
220                                                }
221                                                var tbl = _this.affectSel.getValue();
222                                                if (tbl.length) {
223                                                    o.params.on_table = tbl;
224                                                }
225                                                act = _this.dateFrom.getValue();
226                                                if (act.format) {
227                                                    o.params['query[from]'] = act.format('Y-m-d');
228                                                }
229                                                act = _this.dateTo.getValue();
230                                                if (act.format) {
231                                                    o.params['query[to]'] = act.format('Y-m-d');
232                                                }
233                                             
234                                                
235                                                /*
236                                                act = _this.groupedCombo.getValue();
237                                                o.params['query[grouped]'] = act;
238                                                if (o.params['query[grouped]'] == 'gr') {
239                                                
240                                                    if (!tbl.length) {
241                                                        Roo.MessageBox.alert("Error", "Select a table to group results on");
242                                                        return false;
243                                                    }
244                                            //        o.params['_columns']  = 
245                                                    o.params['_distinct'] = 'on_id';
246                                                    
247                                                    
248                                                }
249                                                
250                                                */
251                                            
252                                                
253                                            }
254                                 },
255                                 items : [
256
257                                 ]
258
259                             },
260                             footer : {
261                                 '|xns' : 'Roo',
262                                 pageSize : 25,
263                                 xtype : 'PagingToolbar',
264                                 emptyMsg : "No Events found",
265                                 xns : Roo,
266                                 displayInfo : true,
267                                 displayMsg : "Displaying Events  {0} - {1} of {2}",
268                                 items : [
269                                         {
270                                         '|xns' : 'Roo.Toolbar',
271                                         text : "Download to Excel",
272                                         xtype : 'Button',
273                                         xns : Roo.Toolbar,
274                                         listeners : {
275                                                 click : function (_self, e)
276                                                    {
277                                                        
278                                                        var params = {
279                                                            'sort' : 'event_when',
280                                                            'dir' : 'DESC',
281                                                            'start' : 0,
282                                                            'limit' : 900,
283                                                            person_id : _this.personSel.getValue(), 
284                                                            'csvTitles[0]' : 'When',   'csvCols[0]' : 'event_when', 
285                                                            'csvTitles[1]' : 'Staff',   'csvCols[1]' : 'person_id_name', 
286                                                            'csvTitles[2]' : 'Action',   'csvCols[2]' : 'action', 
287                                                            'csvTitles[3]' : 'Record ID',   'csvCols[3]' : 'on_id'       ,
288                                                            'csvTitles[4]' : 'Record Type',   'csvCols[4]' : 'on_table',
289                                                            'csvTitles[5]' : 'Remarks',   'csvCols[5]' : 'remarks'        
290                                                        }
291                                                            
292                                                        params.person_id = _this.personSel.getValue();
293                                                        var act = _this.actionSel.getValue();
294                                                        if (act.length) {
295                                                            params.action = act;
296                                                        }
297                                                        var tbl = _this.affectSel.getValue();
298                                                        if (tbl.length) {
299                                                            params.on_table = tbl;
300                                                        }
301                                                        act = _this.dateFrom.getValue();
302                                                        if (act.format) {
303                                                            params['query[from]'] = act.format('Y-m-d');
304                                                        }
305                                                        act = _this.dateTo.getValue();
306                                                        if (act.format) {
307                                                            params['query[to]'] = act.format('Y-m-d');
308                                                        }
309                                                        params.limit = 9999;
310                                                        
311                                                    
312                                                        new Pman.download({
313                                                            url : baseURL + '/Roo/Events.php',
314                                                            params : params ,
315                                                            newWindow: true
316                                                            
317                                                        });
318                                                    }
319                                         }
320                                     }
321                                 ]
322
323                             },
324                             toolbar : {
325                                 '|xns' : 'Roo',
326                                 xtype : 'Toolbar',
327                                 xns : Roo,
328                                 items : [
329                                         {
330                                         '|xns' : 'Roo.Toolbar',
331                                         text : "Show",
332                                         xtype : 'TextItem',
333                                         xns : Roo.Toolbar
334                                     },
335                                         {
336                                         store : {
337                                             '|xns' : 'Roo.data',
338                                             data : (function() { 
339                                             
340                                                 Roo.log('test');
341                                                 if(typeof(uiConfig.events_person_table) != 'undefined' && uiConfig.events_person_table.length){
342                                                     Roo.log('got');
343                                                     return [];        
344                                                 }
345                                                 Roo.log(uiConfig.events_person_table);
346                                                 return ['Person', 'cntct'];
347                                                 
348                                             })(),
349                                             xtype : 'SimpleStore',
350                                             fields : [ 'value' ],
351                                             xns : Roo.data,
352                                             isLocal : true
353                                         },
354                                         '|xns' : 'Roo.form',
355                                         listWidth : 300,
356                                         triggerAction : 'all',
357                                         forceSelection : true,
358                                         selectOnFocus : true,
359                                         pageSize : 20,
360                                         displayField : 'value',
361                                         emptyText : "Select Person Table",
362                                         minChars : 2,
363                                         value : "Person",
364                                         valueField : 'value',
365                                         xtype : 'ComboBox',
366                                         allowBlank : true,
367                                         typeAhead : true,
368                                         alwaysQuery : true,
369                                         editable : false,
370                                         width : 150,
371                                         xns : Roo.form,
372                                         name : 'person_table',
373                                         qtip : "Select Person Table",
374                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{value}</b> </div>',
375                                         loadingText : "Searching...",
376                                         listeners : {
377                                                 render : function (_self)
378                                                    {
379                                                      _this.tableSel = _self;
380                                                    },
381                                                 select : function (combo, record, index)
382                                                    {
383                                                      _this.grid.footer.onClick('first');
384                                                    }
385                                         },
386                                         items : [
387
388                                         ]
389
390                                     },
391                                         {
392                                         store : {
393                                             proxy : {
394                                                 '|xns' : 'Roo.data',
395                                                 url : baseURL + '/Roo/Person.php',
396                                                 xtype : 'HttpProxy',
397                                                 method : 'GET',
398                                                 xns : Roo.data
399                                             },
400                                             reader : {
401                                                 '|xns' : 'Roo.data',
402                                                 id : 'id',
403                                                 root : 'data',
404                                                 xtype : 'JsonReader',
405                                                 fields : [
406                                                     {
407                                                         'name': 'id',
408                                                         'type': 'int'
409                                                     },
410                                                     {
411                                                         'name': 'office_id',
412                                                         'type': 'int'
413                                                     },
414                                                     {
415                                                         'name': 'name',
416                                                         'type': 'string'
417                                                     },
418                                                     {
419                                                         'name': 'phone',
420                                                         'type': 'string'
421                                                     },
422                                                     {
423                                                         'name': 'fax',
424                                                         'type': 'string'
425                                                     },
426                                                     {
427                                                         'name': 'email',
428                                                         'type': 'string'
429                                                     },
430                                                     {
431                                                         'name': 'company_id',
432                                                         'type': 'int'
433                                                     },
434                                                     {
435                                                         'name': 'role',
436                                                         'type': 'string'
437                                                     },
438                                                     {
439                                                         'name': 'active',
440                                                         'type': 'int'
441                                                     },
442                                                     {
443                                                         'name': 'remarks',
444                                                         'type': 'string'
445                                                     },
446                                                     {
447                                                         'name': 'passwd',
448                                                         'type': 'string'
449                                                     },
450                                                     {
451                                                         'name': 'owner_id',
452                                                         'type': 'int'
453                                                     },
454                                                     {
455                                                         'name': 'lang',
456                                                         'type': 'string'
457                                                     },
458                                                     {
459                                                         'name': 'no_reset_sent',
460                                                         'type': 'int'
461                                                     },
462                                                     {
463                                                         'name': 'action_type',
464                                                         'type': 'string'
465                                                     },
466                                                     {
467                                                         'name': 'project_id',
468                                                         'type': 'int'
469                                                     },
470                                                     {
471                                                         'name': 'deleted_by',
472                                                         'type': 'int'
473                                                     },
474                                                     {
475                                                         'name': 'deleted_dt',
476                                                         'type': 'date',
477                                                         'dateFormat': 'Y-m-d'
478                                                     },
479                                                     {
480                                                         'name': 'office_id_id',
481                                                         'type': 'int'
482                                                     },
483                                                     {
484                                                         'name': 'office_id_company_id',
485                                                         'type': 'int'
486                                                     },
487                                                     {
488                                                         'name': 'office_id_name',
489                                                         'type': 'string'
490                                                     },
491                                                     {
492                                                         'name': 'office_id_address',
493                                                         'type': 'string'
494                                                     },
495                                                     {
496                                                         'name': 'office_id_phone',
497                                                         'type': 'string'
498                                                     },
499                                                     {
500                                                         'name': 'office_id_fax',
501                                                         'type': 'string'
502                                                     },
503                                                     {
504                                                         'name': 'office_id_email',
505                                                         'type': 'string'
506                                                     },
507                                                     {
508                                                         'name': 'office_id_role',
509                                                         'type': 'string'
510                                                     },
511                                                     {
512                                                         'name': 'company_id_code',
513                                                         'type': 'string'
514                                                     },
515                                                     {
516                                                         'name': 'company_id_name',
517                                                         'type': 'string'
518                                                     },
519                                                     {
520                                                         'name': 'company_id_remarks',
521                                                         'type': 'string'
522                                                     },
523                                                     {
524                                                         'name': 'company_id_owner_id',
525                                                         'type': 'int'
526                                                     },
527                                                     {
528                                                         'name': 'company_id_address',
529                                                         'type': 'string'
530                                                     },
531                                                     {
532                                                         'name': 'company_id_tel',
533                                                         'type': 'string'
534                                                     },
535                                                     {
536                                                         'name': 'company_id_fax',
537                                                         'type': 'string'
538                                                     },
539                                                     {
540                                                         'name': 'company_id_email',
541                                                         'type': 'string'
542                                                     },
543                                                     {
544                                                         'name': 'company_id_id',
545                                                         'type': 'int'
546                                                     },
547                                                     {
548                                                         'name': 'company_id_isOwner',
549                                                         'type': 'int'
550                                                     },
551                                                     {
552                                                         'name': 'company_id_logo_id',
553                                                         'type': 'int'
554                                                     },
555                                                     {
556                                                         'name': 'company_id_background_color',
557                                                         'type': 'string'
558                                                     },
559                                                     {
560                                                         'name': 'company_id_comptype',
561                                                         'type': 'string'
562                                                     },
563                                                     {
564                                                         'name': 'company_id_url',
565                                                         'type': 'string'
566                                                     },
567                                                     {
568                                                         'name': 'company_id_main_office_id',
569                                                         'type': 'int'
570                                                     },
571                                                     {
572                                                         'name': 'company_id_created_by',
573                                                         'type': 'int'
574                                                     },
575                                                     {
576                                                         'name': 'company_id_created_dt',
577                                                         'type': 'date'
578                                                     },
579                                                     {
580                                                         'name': 'company_id_updated_by',
581                                                         'type': 'int'
582                                                     },
583                                                     {
584                                                         'name': 'company_id_updated_dt',
585                                                         'type': 'date'
586                                                     },
587                                                     {
588                                                         'name': 'company_id_passwd',
589                                                         'type': 'string'
590                                                     },
591                                                     {
592                                                         'name': 'company_id_dispatch_port',
593                                                         'type': 'string'
594                                                     },
595                                                     {
596                                                         'name': 'company_id_province',
597                                                         'type': 'string'
598                                                     },
599                                                     {
600                                                         'name': 'company_id_country',
601                                                         'type': 'string'
602                                                     },
603                                                     {
604                                                         'name': 'project_id_id',
605                                                         'type': 'int'
606                                                     },
607                                                     {
608                                                         'name': 'project_id_name',
609                                                         'type': 'string'
610                                                     },
611                                                     {
612                                                         'name': 'project_id_remarks',
613                                                         'type': 'string'
614                                                     },
615                                                     {
616                                                         'name': 'project_id_owner_id',
617                                                         'type': 'int'
618                                                     },
619                                                     {
620                                                         'name': 'project_id_code',
621                                                         'type': 'string'
622                                                     },
623                                                     {
624                                                         'name': 'project_id_active',
625                                                         'type': 'int'
626                                                     },
627                                                     {
628                                                         'name': 'project_id_type',
629                                                         'type': 'string'
630                                                     },
631                                                     {
632                                                         'name': 'project_id_client_id',
633                                                         'type': 'int'
634                                                     },
635                                                     {
636                                                         'name': 'project_id_team_id',
637                                                         'type': 'int'
638                                                     },
639                                                     {
640                                                         'name': 'project_id_file_location',
641                                                         'type': 'string'
642                                                     },
643                                                     {
644                                                         'name': 'project_id_open_date',
645                                                         'type': 'date'
646                                                     },
647                                                     {
648                                                         'name': 'project_id_open_by',
649                                                         'type': 'int'
650                                                     },
651                                                     {
652                                                         'name': 'project_id_close_date',
653                                                         'type': 'date'
654                                                     },
655                                                     {
656                                                         'name': 'project_id_countries',
657                                                         'type': 'string'
658                                                     },
659                                                     {
660                                                         'name': 'project_id_languages',
661                                                         'type': 'string'
662                                                     },
663                                                     {
664                                                         'name': 'project_id_agency_id',
665                                                         'type': 'int'
666                                                     },
667                                                     {
668                                                         'name': 'owner_id_id',
669                                                         'type': 'int'
670                                                     },
671                                                     {
672                                                         'name': 'owner_id_office_id',
673                                                         'type': 'int'
674                                                     },
675                                                     {
676                                                         'name': 'owner_id_name',
677                                                         'type': 'string'
678                                                     },
679                                                     {
680                                                         'name': 'owner_id_phone',
681                                                         'type': 'string'
682                                                     },
683                                                     {
684                                                         'name': 'owner_id_fax',
685                                                         'type': 'string'
686                                                     },
687                                                     {
688                                                         'name': 'owner_id_email',
689                                                         'type': 'string'
690                                                     },
691                                                     {
692                                                         'name': 'owner_id_company_id',
693                                                         'type': 'int'
694                                                     },
695                                                     {
696                                                         'name': 'owner_id_role',
697                                                         'type': 'string'
698                                                     },
699                                                     {
700                                                         'name': 'owner_id_active',
701                                                         'type': 'int'
702                                                     },
703                                                     {
704                                                         'name': 'owner_id_remarks',
705                                                         'type': 'string'
706                                                     },
707                                                     {
708                                                         'name': 'owner_id_passwd',
709                                                         'type': 'string'
710                                                     },
711                                                     {
712                                                         'name': 'owner_id_owner_id',
713                                                         'type': 'int'
714                                                     },
715                                                     {
716                                                         'name': 'owner_id_lang',
717                                                         'type': 'string'
718                                                     },
719                                                     {
720                                                         'name': 'owner_id_no_reset_sent',
721                                                         'type': 'int'
722                                                     },
723                                                     {
724                                                         'name': 'owner_id_action_type',
725                                                         'type': 'string'
726                                                     },
727                                                     {
728                                                         'name': 'owner_id_project_id',
729                                                         'type': 'int'
730                                                     },
731                                                     {
732                                                         'name': 'owner_id_deleted_by',
733                                                         'type': 'int'
734                                                     },
735                                                     {
736                                                         'name': 'owner_id_deleted_dt',
737                                                         'type': 'date'
738                                                     }
739                                                 ],
740                                                 xns : Roo.data,
741                                                 totalProperty : 'total'
742                                             },
743                                             '|xns' : 'Roo.data',
744                                             xtype : 'Store',
745                                             remoteSort : true,
746                                             sortInfo : { field : 'name' , direction : 'ASC' },
747                                             xns : Roo.data,
748                                             listeners : {
749                                                 beforeload : function (_self, o)
750                                                    {
751                                                        o.params = o.params || {};
752                                                        o.params.company_id = Pman.Login.authUser.company_id;
753                                                    }
754                                             },
755                                             items : [
756
757                                             ]
758
759                                         },
760                                         '|xns' : 'Roo.form',
761                                         listWidth : 600,
762                                         triggerAction : 'all',
763                                         fieldLabel : 'Person ',
764                                         forceSelection : true,
765                                         selectOnFocus : true,
766                                         pageSize : 20,
767                                         displayField : 'name',
768                                         emptyText : "Select Person ",
769                                         minChars : 2,
770                                         valueField : 'id',
771                                         xtype : 'ComboBox',
772                                         allowBlank : true,
773                                         typeAhead : true,
774                                         editable : true,
775                                         width : 150,
776                                         xns : Roo.form,
777                                         name : 'person_id_name',
778                                         qtip : "Select Person ",
779                                         queryParam : 'query[name]',
780                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> ({company_id_name}) &lt;{email}&gt; </div>',
781                                         loadingText : "Searching...",
782                                         listeners : {
783                                                 render : function (_self)
784                                                    {
785                                                      _this.personSel = _self;
786                                                    },
787                                                 select : function (combo, record, index)
788                                                    {
789                                                      _this.grid.footer.onClick('first');
790                                                      
791                                                    }
792                                         },
793                                         items : [
794
795                                         ]
796
797                                     },
798                                         {
799                                         store : {
800                                             proxy : {
801                                                 '|xns' : 'Roo.data',
802                                                 url : baseURL + '/Roo/Events.php',
803                                                 xtype : 'HttpProxy',
804                                                 method : 'GET',
805                                                 xns : Roo.data
806                                             },
807                                             reader : {
808                                                 '|xns' : 'Roo.data',
809                                                 id : 'id',
810                                                 root : 'data',
811                                                 xtype : 'JsonReader',
812                                                 fields : [
813                                                     {
814                                                         'name': 'id',
815                                                         'type': 'int'
816                                                     },
817                                                     {
818                                                         'name': 'person_name',
819                                                         'type': 'string'
820                                                     },
821                                                     {
822                                                         'name': 'event_when',
823                                                         'type': 'date',
824                                                         'dateFormat': 'Y-m-d'
825                                                     },
826                                                     {
827                                                         'name': 'action',
828                                                         'type': 'string'
829                                                     },
830                                                     {
831                                                         'name': 'ipaddr',
832                                                         'type': 'string'
833                                                     },
834                                                     {
835                                                         'name': 'on_id',
836                                                         'type': 'int'
837                                                     },
838                                                     {
839                                                         'name': 'on_table',
840                                                         'type': 'string'
841                                                     },
842                                                     {
843                                                         'name': 'person_id',
844                                                         'type': 'int'
845                                                     },
846                                                     {
847                                                         'name': 'remarks',
848                                                         'type': 'string'
849                                                     },
850                                                     {
851                                                         'name': 'person_id_id',
852                                                         'type': 'int'
853                                                     },
854                                                     {
855                                                         'name': 'person_id_office_id',
856                                                         'type': 'int'
857                                                     },
858                                                     {
859                                                         'name': 'person_id_name',
860                                                         'type': 'string'
861                                                     },
862                                                     {
863                                                         'name': 'person_id_phone',
864                                                         'type': 'string'
865                                                     },
866                                                     {
867                                                         'name': 'person_id_fax',
868                                                         'type': 'string'
869                                                     },
870                                                     {
871                                                         'name': 'person_id_email',
872                                                         'type': 'string'
873                                                     },
874                                                     {
875                                                         'name': 'person_id_company_id',
876                                                         'type': 'int'
877                                                     },
878                                                     {
879                                                         'name': 'person_id_role',
880                                                         'type': 'string'
881                                                     },
882                                                     {
883                                                         'name': 'person_id_active',
884                                                         'type': 'int'
885                                                     },
886                                                     {
887                                                         'name': 'person_id_remarks',
888                                                         'type': 'string'
889                                                     },
890                                                     {
891                                                         'name': 'person_id_passwd',
892                                                         'type': 'string'
893                                                     },
894                                                     {
895                                                         'name': 'person_id_owner_id',
896                                                         'type': 'int'
897                                                     },
898                                                     {
899                                                         'name': 'person_id_lang',
900                                                         'type': 'string'
901                                                     },
902                                                     {
903                                                         'name': 'person_id_no_reset_sent',
904                                                         'type': 'int'
905                                                     },
906                                                     {
907                                                         'name': 'person_id_action_type',
908                                                         'type': 'string'
909                                                     },
910                                                     {
911                                                         'name': 'person_id_project_id',
912                                                         'type': 'int'
913                                                     },
914                                                     {
915                                                         'name': 'person_id_deleted_by',
916                                                         'type': 'int'
917                                                     },
918                                                     {
919                                                         'name': 'person_id_deleted_dt',
920                                                         'type': 'date'
921                                                     }
922                                                 ],
923                                                 xns : Roo.data,
924                                                 totalProperty : 'total'
925                                             },
926                                             '|xns' : 'Roo.data',
927                                             xtype : 'Store',
928                                             remoteSort : true,
929                                             sortInfo : { field : 'action' , direction : 'ASC' },
930                                             xns : Roo.data,
931                                             listeners : {
932                                                 beforeload : function (_self, o)
933                                                    {
934                                                        o.params = o.params || {};
935                                                        // staff can see all logs, other companies can only see their own.
936                                                        if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
937                                                            o.params.company_id = Pman.Login.authUser.company_id;
938                                                        }
939                                                        o.params._distinct = 'action';
940                                                        o.params._columns ='action';
941                                                    }
942                                             },
943                                             items : [
944
945                                             ]
946
947                                         },
948                                         '|xns' : 'Roo.form',
949                                         listWidth : 300,
950                                         triggerAction : 'all',
951                                         forceSelection : true,
952                                         selectOnFocus : true,
953                                         pageSize : 20,
954                                         displayField : 'action',
955                                         emptyText : "Select Action",
956                                         minChars : 2,
957                                         valueField : 'action',
958                                         xtype : 'ComboBox',
959                                         allowBlank : true,
960                                         typeAhead : true,
961                                         editable : true,
962                                         width : 150,
963                                         xns : Roo.form,
964                                         name : 'action',
965                                         qtip : "Select Action",
966                                         queryParam : 'query[action]',
967                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{action}</b> </div>',
968                                         loadingText : "Searching...",
969                                         listeners : {
970                                                 render : function (_self)
971                                                    {
972                                                      _this.actionSel = _self;
973                                                    },
974                                                 select : function (combo, record, index)
975                                                    {
976                                                      _this.grid.footer.onClick('first');
977                                                    }
978                                         },
979                                         items : [
980
981                                         ]
982
983                                     },
984                                         {
985                                         store : {
986                                             proxy : {
987                                                 '|xns' : 'Roo.data',
988                                                 url : baseURL + '/Roo/Events.php',
989                                                 xtype : 'HttpProxy',
990                                                 method : 'GET',
991                                                 xns : Roo.data
992                                             },
993                                             reader : {
994                                                 '|xns' : 'Roo.data',
995                                                 id : 'id',
996                                                 root : 'data',
997                                                 xtype : 'JsonReader',
998                                                 xns : Roo.data,
999                                                 fields : [
1000                                                     {
1001                                                         'name': 'id',
1002                                                         'type': 'int'
1003                                                     },
1004                                                     {
1005                                                         'name': 'person_name',
1006                                                         'type': 'string'
1007                                                     },
1008                                                     {
1009                                                         'name': 'event_when',
1010                                                         'type': 'date',
1011                                                         'dateFormat': 'Y-m-d'
1012                                                     },
1013                                                     {
1014                                                         'name': 'action',
1015                                                         'type': 'string'
1016                                                     },
1017                                                     {
1018                                                         'name': 'ipaddr',
1019                                                         'type': 'string'
1020                                                     },
1021                                                     {
1022                                                         'name': 'on_id',
1023                                                         'type': 'int'
1024                                                     },
1025                                                     {
1026                                                         'name': 'on_table',
1027                                                         'type': 'string'
1028                                                     },
1029                                                     {
1030                                                         'name': 'person_id',
1031                                                         'type': 'int'
1032                                                     },
1033                                                     {
1034                                                         'name': 'remarks',
1035                                                         'type': 'string'
1036                                                     },
1037                                                     {
1038                                                         'name': 'person_id_id',
1039                                                         'type': 'int'
1040                                                     },
1041                                                     {
1042                                                         'name': 'person_id_office_id',
1043                                                         'type': 'int'
1044                                                     },
1045                                                     {
1046                                                         'name': 'person_id_name',
1047                                                         'type': 'string'
1048                                                     },
1049                                                     {
1050                                                         'name': 'person_id_phone',
1051                                                         'type': 'string'
1052                                                     },
1053                                                     {
1054                                                         'name': 'person_id_fax',
1055                                                         'type': 'string'
1056                                                     },
1057                                                     {
1058                                                         'name': 'person_id_email',
1059                                                         'type': 'string'
1060                                                     },
1061                                                     {
1062                                                         'name': 'person_id_company_id',
1063                                                         'type': 'int'
1064                                                     },
1065                                                     {
1066                                                         'name': 'person_id_role',
1067                                                         'type': 'string'
1068                                                     },
1069                                                     {
1070                                                         'name': 'person_id_active',
1071                                                         'type': 'int'
1072                                                     },
1073                                                     {
1074                                                         'name': 'person_id_remarks',
1075                                                         'type': 'string'
1076                                                     },
1077                                                     {
1078                                                         'name': 'person_id_passwd',
1079                                                         'type': 'string'
1080                                                     },
1081                                                     {
1082                                                         'name': 'person_id_owner_id',
1083                                                         'type': 'int'
1084                                                     },
1085                                                     {
1086                                                         'name': 'person_id_lang',
1087                                                         'type': 'string'
1088                                                     },
1089                                                     {
1090                                                         'name': 'person_id_no_reset_sent',
1091                                                         'type': 'int'
1092                                                     },
1093                                                     {
1094                                                         'name': 'person_id_action_type',
1095                                                         'type': 'string'
1096                                                     },
1097                                                     {
1098                                                         'name': 'person_id_project_id',
1099                                                         'type': 'int'
1100                                                     },
1101                                                     {
1102                                                         'name': 'person_id_deleted_by',
1103                                                         'type': 'int'
1104                                                     },
1105                                                     {
1106                                                         'name': 'person_id_deleted_dt',
1107                                                         'type': 'date'
1108                                                     }
1109                                                 ],
1110                                                 totalProperty : 'total'
1111                                             },
1112                                             '|xns' : 'Roo.data',
1113                                             xtype : 'Store',
1114                                             remoteSort : true,
1115                                             sortInfo : { field : 'on_table' , direction : 'ASC' },
1116                                             xns : Roo.data,
1117                                             listeners : {
1118                                                 beforeload : function (_self, o)
1119                                                    {
1120                                                        o.params = o.params || {};
1121                                                        // staff can see all logs, other companies can only see their own.
1122                                                        if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
1123                                                            o.params.company_id = Pman.Login.authUser.company_id;
1124                                                        }
1125                                                        o.params._distinct = 'on_table';
1126                                                        o.params._columns ='on_table';
1127                                                    }
1128                                             },
1129                                             items : [
1130
1131                                             ]
1132
1133                                         },
1134                                         '|xns' : 'Roo.form',
1135                                         listWidth : 300,
1136                                         triggerAction : 'all',
1137                                         forceSelection : true,
1138                                         selectOnFocus : true,
1139                                         pageSize : 20,
1140                                         displayField : 'on_table',
1141                                         emptyText : "Select Affects",
1142                                         minChars : 2,
1143                                         valueField : 'action',
1144                                         xtype : 'ComboBox',
1145                                         allowBlank : true,
1146                                         typeAhead : true,
1147                                         editable : true,
1148                                         width : 150,
1149                                         xns : Roo.form,
1150                                         name : 'on_table',
1151                                         qtip : "Select Action",
1152                                         queryParam : 'query[on_table]',
1153                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{on_table}</b> </div>',
1154                                         loadingText : "Searching...",
1155                                         listeners : {
1156                                                 render : function (_self)
1157                                                    {
1158                                                      _this.affectSel = _self;
1159                                                    },
1160                                                 select : function (combo, record, index)
1161                                                    {
1162                                                      _this.grid.footer.onClick('first');
1163                                                    }
1164                                         },
1165                                         items : [
1166
1167                                         ]
1168
1169                                     },
1170                                         {
1171                                         '|xns' : 'Roo.Toolbar',
1172                                         text : "Date Range",
1173                                         xtype : 'TextItem',
1174                                         xns : Roo.Toolbar
1175                                     },
1176                                         {
1177                                         '|xns' : 'Roo.form',
1178                                         format : 'Y-m-d',
1179                                         xtype : 'DateField',
1180                                         xns : Roo.form,
1181                                         listeners : {
1182                                                 render : function (_self)
1183                                                    {
1184                                                      _this.dateFrom = _self;
1185                                                    },
1186                                                 change : function (_self, newValue, oldValue)
1187                                                    {
1188                                                      _this.grid.footer.onClick('first');
1189                                                    }
1190                                         }
1191                                     },
1192                                         {
1193                                         '|xns' : 'Roo.form',
1194                                         format : 'Y-m-d',
1195                                         xtype : 'DateField',
1196                                         xns : Roo.form,
1197                                         listeners : {
1198                                                 render : function (_self)
1199                                                    {
1200                                                      _this.dateTo = _self;
1201                                                    },
1202                                                 change : function (_self, newValue, oldValue)
1203                                                    {
1204                                                      _this.grid.footer.onClick('first');
1205                                                    }
1206                                         }
1207                                     }
1208                                 ]
1209
1210                             },
1211                             '|xns' : 'Roo.grid',
1212                             autoExpandColumn : 'remarks',
1213                             xtype : 'Grid',
1214                             loadMask : true,
1215                             xns : Roo.grid,
1216                             colModel : [
1217                                  {
1218                                         '|xns' : 'Roo.grid',
1219                                         xtype : 'ColumnModel',
1220                                         header : 'When',
1221                                         width : 100,
1222                                         renderer : function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; },
1223                                         xns : Roo.grid,
1224                                         dataIndex : 'event_when'
1225                                     },
1226 {
1227                                         '|xns' : 'Roo.grid',
1228                                         xtype : 'ColumnModel',
1229                                         header : '#id',
1230                                         width : 100,
1231                                         xns : Roo.grid,
1232                                         dataIndex : 'id'
1233                                     },
1234 {
1235                                         '|xns' : 'Roo.grid',
1236                                         xtype : 'ColumnModel',
1237                                         header : 'Staff',
1238                                         width : 150,
1239                                         renderer : function(v,x,r) { 
1240                                             
1241                                             var efield = typeof(_this.email_field) == 'undefined' ? 'person_id_email' : _this.email_field;
1242                                             var nfield = typeof(_this.name_field) == 'undefined' ? 'person_id_name' : _this.name_field;    
1243                                             
1244                                             Roo.log([r, efield, nfield]);
1245                                             
1246                                             var email = r.json[efield]; // ? r.data.person_id_email : r.data.person_id_email;
1247                                             var name  = r.json[nfield]; // ? r.data.person_id_name : r.data.person_id_name;    
1248                                             return String.format('{0} &lt;<a href="mailto:{1}">{1}</a>&gt;', 
1249                                                 name, email); 
1250                                         
1251                                         
1252                                         },
1253                                         xns : Roo.grid,
1254                                         dataIndex : 'person_id_name'
1255                                     },
1256 {
1257                                         '|xns' : 'Roo.grid',
1258                                         xtype : 'ColumnModel',
1259                                         width : 100,
1260                                         header : 'Action',
1261                                         renderer : function(v) { return String.format('{0}', v); },
1262                                         xns : Roo.grid,
1263                                         dataIndex : 'action'
1264                                     },
1265 {
1266                                         '|xns' : 'Roo.grid',
1267                                         xtype : 'ColumnModel',
1268                                         width : 100,
1269                                         header : 'IP',
1270                                         renderer : function(v) { return String.format('{0}', v); },
1271                                         xns : Roo.grid,
1272                                         dataIndex : 'ipaddr'
1273                                     },
1274 {
1275                                         '|xns' : 'Roo.grid',
1276                                         xtype : 'ColumnModel',
1277                                         header : 'Affected',
1278                                         width : 100,
1279                                         renderer : function(v, x, r) {                     
1280                                                     return v ? String.format('{0}({1})', v,  r.data.on_id)  : '';  
1281                                            },
1282                                         xns : Roo.grid,
1283                                         dataIndex : 'on_table'
1284                                     },
1285 {
1286                                         '|xns' : 'Roo.grid',
1287                                         xtype : 'ColumnModel',
1288                                         header : 'Remarks',
1289                                         width : 300,
1290                                         renderer : function(v) { return String.format('<span qtip="{1}">{0}</span>', v, Roo.util.Format.htmlEncode(v)); },
1291                                         xns : Roo.grid,
1292                                         dataIndex : 'remarks'
1293                                     }
1294                             ],
1295                             listeners : {
1296                                 render : function() { 
1297                                        _this.grid = this; 
1298                                        //_this.dialog = Pman.Dialog.FILL_IN
1299                                        if (_this.panel.active) {
1300                                           this.footer.onClick('first');
1301                                        }
1302                                    }
1303                             },
1304                             items : [
1305
1306                             ]
1307
1308                         },
1309                         '|xns' : 'Roo',
1310                         fitToframe : true,
1311                         background : false,
1312                         region : 'center',
1313                         title : "Events",
1314                         xtype : 'GridPanel',
1315                         fitContainer : true,
1316                         xns : Roo,
1317                         tableName : 'Events',
1318                         listeners : {
1319                                 activate : function() {
1320                                        _this.panel = this;
1321                                        if (_this.grid) {
1322                                            _this.grid.footer.onClick('first');
1323                                        }
1324                                    }
1325                         },
1326                         items : [
1327
1328                         ]
1329
1330                     }
1331                 ]
1332
1333             },
1334             '|xns' : 'Roo',
1335             region : 'center',
1336             xtype : 'NestedLayoutPanel',
1337             title : "Events",
1338             xns : Roo,
1339             items : [
1340
1341             ]
1342
1343         };    }
1344 });