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                                                 if(typeof(uiConfig.events_person_table) == 'undefined' || !uiConfig.events_person_table.length){
341                                             
342                                                     return [];        
343                                                 }
344                                             
345                                                 return [['test'], ['test2']];
346                                                 
347                                             })(),
348                                             xtype : 'SimpleStore',
349                                             fields : [ 'value' ],
350                                             xns : Roo.data,
351                                             isLocal : true
352                                         },
353                                         '|xns' : 'Roo.form',
354                                         listWidth : 300,
355                                         triggerAction : 'all',
356                                         forceSelection : true,
357                                         selectOnFocus : true,
358                                         pageSize : 20,
359                                         displayField : 'value',
360                                         emptyText : "Select Person Table",
361                                         minChars : 2,
362                                         valueField : 'value',
363                                         xtype : 'ComboBox',
364                                         allowBlank : true,
365                                         typeAhead : true,
366                                         alwaysQuery : true,
367                                         editable : false,
368                                         width : 150,
369                                         xns : Roo.form,
370                                         name : 'person_table',
371                                         qtip : "Select Person Table",
372                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{value}</b> </div>',
373                                         loadingText : "Searching...",
374                                         listeners : {
375                                                 render : function (_self)
376                                                    {
377                                                      _this.tableSel = _self;
378                                                    },
379                                                 select : function (combo, record, index)
380                                                    {
381                                                      _this.grid.footer.onClick('first');
382                                                    }
383                                         },
384                                         items : [
385
386                                         ]
387
388                                     },
389                                         {
390                                         store : {
391                                             proxy : {
392                                                 '|xns' : 'Roo.data',
393                                                 url : baseURL + '/Roo/Person.php',
394                                                 xtype : 'HttpProxy',
395                                                 method : 'GET',
396                                                 xns : Roo.data
397                                             },
398                                             reader : {
399                                                 '|xns' : 'Roo.data',
400                                                 id : 'id',
401                                                 root : 'data',
402                                                 xtype : 'JsonReader',
403                                                 fields : [
404                                                     {
405                                                         'name': 'id',
406                                                         'type': 'int'
407                                                     },
408                                                     {
409                                                         'name': 'office_id',
410                                                         'type': 'int'
411                                                     },
412                                                     {
413                                                         'name': 'name',
414                                                         'type': 'string'
415                                                     },
416                                                     {
417                                                         'name': 'phone',
418                                                         'type': 'string'
419                                                     },
420                                                     {
421                                                         'name': 'fax',
422                                                         'type': 'string'
423                                                     },
424                                                     {
425                                                         'name': 'email',
426                                                         'type': 'string'
427                                                     },
428                                                     {
429                                                         'name': 'company_id',
430                                                         'type': 'int'
431                                                     },
432                                                     {
433                                                         'name': 'role',
434                                                         'type': 'string'
435                                                     },
436                                                     {
437                                                         'name': 'active',
438                                                         'type': 'int'
439                                                     },
440                                                     {
441                                                         'name': 'remarks',
442                                                         'type': 'string'
443                                                     },
444                                                     {
445                                                         'name': 'passwd',
446                                                         'type': 'string'
447                                                     },
448                                                     {
449                                                         'name': 'owner_id',
450                                                         'type': 'int'
451                                                     },
452                                                     {
453                                                         'name': 'lang',
454                                                         'type': 'string'
455                                                     },
456                                                     {
457                                                         'name': 'no_reset_sent',
458                                                         'type': 'int'
459                                                     },
460                                                     {
461                                                         'name': 'action_type',
462                                                         'type': 'string'
463                                                     },
464                                                     {
465                                                         'name': 'project_id',
466                                                         'type': 'int'
467                                                     },
468                                                     {
469                                                         'name': 'deleted_by',
470                                                         'type': 'int'
471                                                     },
472                                                     {
473                                                         'name': 'deleted_dt',
474                                                         'type': 'date',
475                                                         'dateFormat': 'Y-m-d'
476                                                     },
477                                                     {
478                                                         'name': 'office_id_id',
479                                                         'type': 'int'
480                                                     },
481                                                     {
482                                                         'name': 'office_id_company_id',
483                                                         'type': 'int'
484                                                     },
485                                                     {
486                                                         'name': 'office_id_name',
487                                                         'type': 'string'
488                                                     },
489                                                     {
490                                                         'name': 'office_id_address',
491                                                         'type': 'string'
492                                                     },
493                                                     {
494                                                         'name': 'office_id_phone',
495                                                         'type': 'string'
496                                                     },
497                                                     {
498                                                         'name': 'office_id_fax',
499                                                         'type': 'string'
500                                                     },
501                                                     {
502                                                         'name': 'office_id_email',
503                                                         'type': 'string'
504                                                     },
505                                                     {
506                                                         'name': 'office_id_role',
507                                                         'type': 'string'
508                                                     },
509                                                     {
510                                                         'name': 'company_id_code',
511                                                         'type': 'string'
512                                                     },
513                                                     {
514                                                         'name': 'company_id_name',
515                                                         'type': 'string'
516                                                     },
517                                                     {
518                                                         'name': 'company_id_remarks',
519                                                         'type': 'string'
520                                                     },
521                                                     {
522                                                         'name': 'company_id_owner_id',
523                                                         'type': 'int'
524                                                     },
525                                                     {
526                                                         'name': 'company_id_address',
527                                                         'type': 'string'
528                                                     },
529                                                     {
530                                                         'name': 'company_id_tel',
531                                                         'type': 'string'
532                                                     },
533                                                     {
534                                                         'name': 'company_id_fax',
535                                                         'type': 'string'
536                                                     },
537                                                     {
538                                                         'name': 'company_id_email',
539                                                         'type': 'string'
540                                                     },
541                                                     {
542                                                         'name': 'company_id_id',
543                                                         'type': 'int'
544                                                     },
545                                                     {
546                                                         'name': 'company_id_isOwner',
547                                                         'type': 'int'
548                                                     },
549                                                     {
550                                                         'name': 'company_id_logo_id',
551                                                         'type': 'int'
552                                                     },
553                                                     {
554                                                         'name': 'company_id_background_color',
555                                                         'type': 'string'
556                                                     },
557                                                     {
558                                                         'name': 'company_id_comptype',
559                                                         'type': 'string'
560                                                     },
561                                                     {
562                                                         'name': 'company_id_url',
563                                                         'type': 'string'
564                                                     },
565                                                     {
566                                                         'name': 'company_id_main_office_id',
567                                                         'type': 'int'
568                                                     },
569                                                     {
570                                                         'name': 'company_id_created_by',
571                                                         'type': 'int'
572                                                     },
573                                                     {
574                                                         'name': 'company_id_created_dt',
575                                                         'type': 'date'
576                                                     },
577                                                     {
578                                                         'name': 'company_id_updated_by',
579                                                         'type': 'int'
580                                                     },
581                                                     {
582                                                         'name': 'company_id_updated_dt',
583                                                         'type': 'date'
584                                                     },
585                                                     {
586                                                         'name': 'company_id_passwd',
587                                                         'type': 'string'
588                                                     },
589                                                     {
590                                                         'name': 'company_id_dispatch_port',
591                                                         'type': 'string'
592                                                     },
593                                                     {
594                                                         'name': 'company_id_province',
595                                                         'type': 'string'
596                                                     },
597                                                     {
598                                                         'name': 'company_id_country',
599                                                         'type': 'string'
600                                                     },
601                                                     {
602                                                         'name': 'project_id_id',
603                                                         'type': 'int'
604                                                     },
605                                                     {
606                                                         'name': 'project_id_name',
607                                                         'type': 'string'
608                                                     },
609                                                     {
610                                                         'name': 'project_id_remarks',
611                                                         'type': 'string'
612                                                     },
613                                                     {
614                                                         'name': 'project_id_owner_id',
615                                                         'type': 'int'
616                                                     },
617                                                     {
618                                                         'name': 'project_id_code',
619                                                         'type': 'string'
620                                                     },
621                                                     {
622                                                         'name': 'project_id_active',
623                                                         'type': 'int'
624                                                     },
625                                                     {
626                                                         'name': 'project_id_type',
627                                                         'type': 'string'
628                                                     },
629                                                     {
630                                                         'name': 'project_id_client_id',
631                                                         'type': 'int'
632                                                     },
633                                                     {
634                                                         'name': 'project_id_team_id',
635                                                         'type': 'int'
636                                                     },
637                                                     {
638                                                         'name': 'project_id_file_location',
639                                                         'type': 'string'
640                                                     },
641                                                     {
642                                                         'name': 'project_id_open_date',
643                                                         'type': 'date'
644                                                     },
645                                                     {
646                                                         'name': 'project_id_open_by',
647                                                         'type': 'int'
648                                                     },
649                                                     {
650                                                         'name': 'project_id_close_date',
651                                                         'type': 'date'
652                                                     },
653                                                     {
654                                                         'name': 'project_id_countries',
655                                                         'type': 'string'
656                                                     },
657                                                     {
658                                                         'name': 'project_id_languages',
659                                                         'type': 'string'
660                                                     },
661                                                     {
662                                                         'name': 'project_id_agency_id',
663                                                         'type': 'int'
664                                                     },
665                                                     {
666                                                         'name': 'owner_id_id',
667                                                         'type': 'int'
668                                                     },
669                                                     {
670                                                         'name': 'owner_id_office_id',
671                                                         'type': 'int'
672                                                     },
673                                                     {
674                                                         'name': 'owner_id_name',
675                                                         'type': 'string'
676                                                     },
677                                                     {
678                                                         'name': 'owner_id_phone',
679                                                         'type': 'string'
680                                                     },
681                                                     {
682                                                         'name': 'owner_id_fax',
683                                                         'type': 'string'
684                                                     },
685                                                     {
686                                                         'name': 'owner_id_email',
687                                                         'type': 'string'
688                                                     },
689                                                     {
690                                                         'name': 'owner_id_company_id',
691                                                         'type': 'int'
692                                                     },
693                                                     {
694                                                         'name': 'owner_id_role',
695                                                         'type': 'string'
696                                                     },
697                                                     {
698                                                         'name': 'owner_id_active',
699                                                         'type': 'int'
700                                                     },
701                                                     {
702                                                         'name': 'owner_id_remarks',
703                                                         'type': 'string'
704                                                     },
705                                                     {
706                                                         'name': 'owner_id_passwd',
707                                                         'type': 'string'
708                                                     },
709                                                     {
710                                                         'name': 'owner_id_owner_id',
711                                                         'type': 'int'
712                                                     },
713                                                     {
714                                                         'name': 'owner_id_lang',
715                                                         'type': 'string'
716                                                     },
717                                                     {
718                                                         'name': 'owner_id_no_reset_sent',
719                                                         'type': 'int'
720                                                     },
721                                                     {
722                                                         'name': 'owner_id_action_type',
723                                                         'type': 'string'
724                                                     },
725                                                     {
726                                                         'name': 'owner_id_project_id',
727                                                         'type': 'int'
728                                                     },
729                                                     {
730                                                         'name': 'owner_id_deleted_by',
731                                                         'type': 'int'
732                                                     },
733                                                     {
734                                                         'name': 'owner_id_deleted_dt',
735                                                         'type': 'date'
736                                                     }
737                                                 ],
738                                                 xns : Roo.data,
739                                                 totalProperty : 'total'
740                                             },
741                                             '|xns' : 'Roo.data',
742                                             xtype : 'Store',
743                                             remoteSort : true,
744                                             sortInfo : { field : 'name' , direction : 'ASC' },
745                                             xns : Roo.data,
746                                             listeners : {
747                                                 beforeload : function (_self, o)
748                                                    {
749                                                        o.params = o.params || {};
750                                                        o.params.company_id = Pman.Login.authUser.company_id;
751                                                    }
752                                             },
753                                             items : [
754
755                                             ]
756
757                                         },
758                                         '|xns' : 'Roo.form',
759                                         listWidth : 600,
760                                         triggerAction : 'all',
761                                         fieldLabel : 'Person ',
762                                         forceSelection : true,
763                                         selectOnFocus : true,
764                                         pageSize : 20,
765                                         displayField : 'name',
766                                         emptyText : "Select Person ",
767                                         minChars : 2,
768                                         valueField : 'id',
769                                         xtype : 'ComboBox',
770                                         allowBlank : true,
771                                         typeAhead : true,
772                                         editable : true,
773                                         width : 150,
774                                         xns : Roo.form,
775                                         name : 'person_id_name',
776                                         qtip : "Select Person ",
777                                         queryParam : 'query[name]',
778                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> ({company_id_name}) &lt;{email}&gt; </div>',
779                                         loadingText : "Searching...",
780                                         listeners : {
781                                                 render : function (_self)
782                                                    {
783                                                      _this.personSel = _self;
784                                                    },
785                                                 select : function (combo, record, index)
786                                                    {
787                                                      _this.grid.footer.onClick('first');
788                                                      
789                                                    }
790                                         },
791                                         items : [
792
793                                         ]
794
795                                     },
796                                         {
797                                         store : {
798                                             proxy : {
799                                                 '|xns' : 'Roo.data',
800                                                 url : baseURL + '/Roo/Events.php',
801                                                 xtype : 'HttpProxy',
802                                                 method : 'GET',
803                                                 xns : Roo.data
804                                             },
805                                             reader : {
806                                                 '|xns' : 'Roo.data',
807                                                 id : 'id',
808                                                 root : 'data',
809                                                 xtype : 'JsonReader',
810                                                 fields : [
811                                                     {
812                                                         'name': 'id',
813                                                         'type': 'int'
814                                                     },
815                                                     {
816                                                         'name': 'person_name',
817                                                         'type': 'string'
818                                                     },
819                                                     {
820                                                         'name': 'event_when',
821                                                         'type': 'date',
822                                                         'dateFormat': 'Y-m-d'
823                                                     },
824                                                     {
825                                                         'name': 'action',
826                                                         'type': 'string'
827                                                     },
828                                                     {
829                                                         'name': 'ipaddr',
830                                                         'type': 'string'
831                                                     },
832                                                     {
833                                                         'name': 'on_id',
834                                                         'type': 'int'
835                                                     },
836                                                     {
837                                                         'name': 'on_table',
838                                                         'type': 'string'
839                                                     },
840                                                     {
841                                                         'name': 'person_id',
842                                                         'type': 'int'
843                                                     },
844                                                     {
845                                                         'name': 'remarks',
846                                                         'type': 'string'
847                                                     },
848                                                     {
849                                                         'name': 'person_id_id',
850                                                         'type': 'int'
851                                                     },
852                                                     {
853                                                         'name': 'person_id_office_id',
854                                                         'type': 'int'
855                                                     },
856                                                     {
857                                                         'name': 'person_id_name',
858                                                         'type': 'string'
859                                                     },
860                                                     {
861                                                         'name': 'person_id_phone',
862                                                         'type': 'string'
863                                                     },
864                                                     {
865                                                         'name': 'person_id_fax',
866                                                         'type': 'string'
867                                                     },
868                                                     {
869                                                         'name': 'person_id_email',
870                                                         'type': 'string'
871                                                     },
872                                                     {
873                                                         'name': 'person_id_company_id',
874                                                         'type': 'int'
875                                                     },
876                                                     {
877                                                         'name': 'person_id_role',
878                                                         'type': 'string'
879                                                     },
880                                                     {
881                                                         'name': 'person_id_active',
882                                                         'type': 'int'
883                                                     },
884                                                     {
885                                                         'name': 'person_id_remarks',
886                                                         'type': 'string'
887                                                     },
888                                                     {
889                                                         'name': 'person_id_passwd',
890                                                         'type': 'string'
891                                                     },
892                                                     {
893                                                         'name': 'person_id_owner_id',
894                                                         'type': 'int'
895                                                     },
896                                                     {
897                                                         'name': 'person_id_lang',
898                                                         'type': 'string'
899                                                     },
900                                                     {
901                                                         'name': 'person_id_no_reset_sent',
902                                                         'type': 'int'
903                                                     },
904                                                     {
905                                                         'name': 'person_id_action_type',
906                                                         'type': 'string'
907                                                     },
908                                                     {
909                                                         'name': 'person_id_project_id',
910                                                         'type': 'int'
911                                                     },
912                                                     {
913                                                         'name': 'person_id_deleted_by',
914                                                         'type': 'int'
915                                                     },
916                                                     {
917                                                         'name': 'person_id_deleted_dt',
918                                                         'type': 'date'
919                                                     }
920                                                 ],
921                                                 xns : Roo.data,
922                                                 totalProperty : 'total'
923                                             },
924                                             '|xns' : 'Roo.data',
925                                             xtype : 'Store',
926                                             remoteSort : true,
927                                             sortInfo : { field : 'action' , direction : 'ASC' },
928                                             xns : Roo.data,
929                                             listeners : {
930                                                 beforeload : function (_self, o)
931                                                    {
932                                                        o.params = o.params || {};
933                                                        // staff can see all logs, other companies can only see their own.
934                                                        if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
935                                                            o.params.company_id = Pman.Login.authUser.company_id;
936                                                        }
937                                                        o.params._distinct = 'action';
938                                                        o.params._columns ='action';
939                                                    }
940                                             },
941                                             items : [
942
943                                             ]
944
945                                         },
946                                         '|xns' : 'Roo.form',
947                                         listWidth : 300,
948                                         triggerAction : 'all',
949                                         forceSelection : true,
950                                         selectOnFocus : true,
951                                         pageSize : 20,
952                                         displayField : 'action',
953                                         emptyText : "Select Action",
954                                         minChars : 2,
955                                         valueField : 'action',
956                                         xtype : 'ComboBox',
957                                         allowBlank : true,
958                                         typeAhead : true,
959                                         editable : true,
960                                         width : 150,
961                                         xns : Roo.form,
962                                         name : 'action',
963                                         qtip : "Select Action",
964                                         queryParam : 'query[action]',
965                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{action}</b> </div>',
966                                         loadingText : "Searching...",
967                                         listeners : {
968                                                 render : function (_self)
969                                                    {
970                                                      _this.actionSel = _self;
971                                                    },
972                                                 select : function (combo, record, index)
973                                                    {
974                                                      _this.grid.footer.onClick('first');
975                                                    }
976                                         },
977                                         items : [
978
979                                         ]
980
981                                     },
982                                         {
983                                         store : {
984                                             proxy : {
985                                                 '|xns' : 'Roo.data',
986                                                 url : baseURL + '/Roo/Events.php',
987                                                 xtype : 'HttpProxy',
988                                                 method : 'GET',
989                                                 xns : Roo.data
990                                             },
991                                             reader : {
992                                                 '|xns' : 'Roo.data',
993                                                 id : 'id',
994                                                 root : 'data',
995                                                 xtype : 'JsonReader',
996                                                 xns : Roo.data,
997                                                 fields : [
998                                                     {
999                                                         'name': 'id',
1000                                                         'type': 'int'
1001                                                     },
1002                                                     {
1003                                                         'name': 'person_name',
1004                                                         'type': 'string'
1005                                                     },
1006                                                     {
1007                                                         'name': 'event_when',
1008                                                         'type': 'date',
1009                                                         'dateFormat': 'Y-m-d'
1010                                                     },
1011                                                     {
1012                                                         'name': 'action',
1013                                                         'type': 'string'
1014                                                     },
1015                                                     {
1016                                                         'name': 'ipaddr',
1017                                                         'type': 'string'
1018                                                     },
1019                                                     {
1020                                                         'name': 'on_id',
1021                                                         'type': 'int'
1022                                                     },
1023                                                     {
1024                                                         'name': 'on_table',
1025                                                         'type': 'string'
1026                                                     },
1027                                                     {
1028                                                         'name': 'person_id',
1029                                                         'type': 'int'
1030                                                     },
1031                                                     {
1032                                                         'name': 'remarks',
1033                                                         'type': 'string'
1034                                                     },
1035                                                     {
1036                                                         'name': 'person_id_id',
1037                                                         'type': 'int'
1038                                                     },
1039                                                     {
1040                                                         'name': 'person_id_office_id',
1041                                                         'type': 'int'
1042                                                     },
1043                                                     {
1044                                                         'name': 'person_id_name',
1045                                                         'type': 'string'
1046                                                     },
1047                                                     {
1048                                                         'name': 'person_id_phone',
1049                                                         'type': 'string'
1050                                                     },
1051                                                     {
1052                                                         'name': 'person_id_fax',
1053                                                         'type': 'string'
1054                                                     },
1055                                                     {
1056                                                         'name': 'person_id_email',
1057                                                         'type': 'string'
1058                                                     },
1059                                                     {
1060                                                         'name': 'person_id_company_id',
1061                                                         'type': 'int'
1062                                                     },
1063                                                     {
1064                                                         'name': 'person_id_role',
1065                                                         'type': 'string'
1066                                                     },
1067                                                     {
1068                                                         'name': 'person_id_active',
1069                                                         'type': 'int'
1070                                                     },
1071                                                     {
1072                                                         'name': 'person_id_remarks',
1073                                                         'type': 'string'
1074                                                     },
1075                                                     {
1076                                                         'name': 'person_id_passwd',
1077                                                         'type': 'string'
1078                                                     },
1079                                                     {
1080                                                         'name': 'person_id_owner_id',
1081                                                         'type': 'int'
1082                                                     },
1083                                                     {
1084                                                         'name': 'person_id_lang',
1085                                                         'type': 'string'
1086                                                     },
1087                                                     {
1088                                                         'name': 'person_id_no_reset_sent',
1089                                                         'type': 'int'
1090                                                     },
1091                                                     {
1092                                                         'name': 'person_id_action_type',
1093                                                         'type': 'string'
1094                                                     },
1095                                                     {
1096                                                         'name': 'person_id_project_id',
1097                                                         'type': 'int'
1098                                                     },
1099                                                     {
1100                                                         'name': 'person_id_deleted_by',
1101                                                         'type': 'int'
1102                                                     },
1103                                                     {
1104                                                         'name': 'person_id_deleted_dt',
1105                                                         'type': 'date'
1106                                                     }
1107                                                 ],
1108                                                 totalProperty : 'total'
1109                                             },
1110                                             '|xns' : 'Roo.data',
1111                                             xtype : 'Store',
1112                                             remoteSort : true,
1113                                             sortInfo : { field : 'on_table' , direction : 'ASC' },
1114                                             xns : Roo.data,
1115                                             listeners : {
1116                                                 beforeload : function (_self, o)
1117                                                    {
1118                                                        o.params = o.params || {};
1119                                                        // staff can see all logs, other companies can only see their own.
1120                                                        if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
1121                                                            o.params.company_id = Pman.Login.authUser.company_id;
1122                                                        }
1123                                                        o.params._distinct = 'on_table';
1124                                                        o.params._columns ='on_table';
1125                                                    }
1126                                             },
1127                                             items : [
1128
1129                                             ]
1130
1131                                         },
1132                                         '|xns' : 'Roo.form',
1133                                         listWidth : 300,
1134                                         triggerAction : 'all',
1135                                         forceSelection : true,
1136                                         selectOnFocus : true,
1137                                         pageSize : 20,
1138                                         displayField : 'on_table',
1139                                         emptyText : "Select Affects",
1140                                         minChars : 2,
1141                                         valueField : 'action',
1142                                         xtype : 'ComboBox',
1143                                         allowBlank : true,
1144                                         typeAhead : true,
1145                                         editable : true,
1146                                         width : 150,
1147                                         xns : Roo.form,
1148                                         name : 'on_table',
1149                                         qtip : "Select Action",
1150                                         queryParam : 'query[on_table]',
1151                                         tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{on_table}</b> </div>',
1152                                         loadingText : "Searching...",
1153                                         listeners : {
1154                                                 render : function (_self)
1155                                                    {
1156                                                      _this.affectSel = _self;
1157                                                    },
1158                                                 select : function (combo, record, index)
1159                                                    {
1160                                                      _this.grid.footer.onClick('first');
1161                                                    }
1162                                         },
1163                                         items : [
1164
1165                                         ]
1166
1167                                     },
1168                                         {
1169                                         '|xns' : 'Roo.Toolbar',
1170                                         text : "Date Range",
1171                                         xtype : 'TextItem',
1172                                         xns : Roo.Toolbar
1173                                     },
1174                                         {
1175                                         '|xns' : 'Roo.form',
1176                                         format : 'Y-m-d',
1177                                         xtype : 'DateField',
1178                                         xns : Roo.form,
1179                                         listeners : {
1180                                                 render : function (_self)
1181                                                    {
1182                                                      _this.dateFrom = _self;
1183                                                    },
1184                                                 change : function (_self, newValue, oldValue)
1185                                                    {
1186                                                      _this.grid.footer.onClick('first');
1187                                                    }
1188                                         }
1189                                     },
1190                                         {
1191                                         '|xns' : 'Roo.form',
1192                                         format : 'Y-m-d',
1193                                         xtype : 'DateField',
1194                                         xns : Roo.form,
1195                                         listeners : {
1196                                                 render : function (_self)
1197                                                    {
1198                                                      _this.dateTo = _self;
1199                                                    },
1200                                                 change : function (_self, newValue, oldValue)
1201                                                    {
1202                                                      _this.grid.footer.onClick('first');
1203                                                    }
1204                                         }
1205                                     }
1206                                 ]
1207
1208                             },
1209                             '|xns' : 'Roo.grid',
1210                             autoExpandColumn : 'remarks',
1211                             xtype : 'Grid',
1212                             loadMask : true,
1213                             xns : Roo.grid,
1214                             colModel : [
1215                                  {
1216                                         '|xns' : 'Roo.grid',
1217                                         xtype : 'ColumnModel',
1218                                         header : 'When',
1219                                         width : 100,
1220                                         renderer : function(v) { return v ? v.dateFormat('d/m/Y H:i') : ''; },
1221                                         xns : Roo.grid,
1222                                         dataIndex : 'event_when'
1223                                     },
1224 {
1225                                         '|xns' : 'Roo.grid',
1226                                         xtype : 'ColumnModel',
1227                                         header : '#id',
1228                                         width : 100,
1229                                         xns : Roo.grid,
1230                                         dataIndex : 'id'
1231                                     },
1232 {
1233                                         '|xns' : 'Roo.grid',
1234                                         xtype : 'ColumnModel',
1235                                         header : 'Staff',
1236                                         width : 150,
1237                                         renderer : function(v,x,r) { 
1238                                             
1239                                             var efield = typeof(_this.email_field) == 'undefined' ? 'person_id_email' : _this.email_field;
1240                                             var nfield = typeof(_this.name_field) == 'undefined' ? 'person_id_name' : _this.name_field;    
1241                                             
1242                                             //Roo.log([r, efield, nfield]);
1243                                             
1244                                             var email = r.json[efield]; // ? r.data.person_id_email : r.data.person_id_email;
1245                                             var name  = r.json[nfield]; // ? r.data.person_id_name : r.data.person_id_name;    
1246                                             return String.format('{0} &lt;<a href="mailto:{1}">{1}</a>&gt;', 
1247                                                 name, email); 
1248                                         
1249                                         
1250                                         },
1251                                         xns : Roo.grid,
1252                                         dataIndex : 'person_id_name'
1253                                     },
1254 {
1255                                         '|xns' : 'Roo.grid',
1256                                         xtype : 'ColumnModel',
1257                                         width : 100,
1258                                         header : 'Action',
1259                                         renderer : function(v) { return String.format('{0}', v); },
1260                                         xns : Roo.grid,
1261                                         dataIndex : 'action'
1262                                     },
1263 {
1264                                         '|xns' : 'Roo.grid',
1265                                         xtype : 'ColumnModel',
1266                                         width : 100,
1267                                         header : 'IP',
1268                                         renderer : function(v) { return String.format('{0}', v); },
1269                                         xns : Roo.grid,
1270                                         dataIndex : 'ipaddr'
1271                                     },
1272 {
1273                                         '|xns' : 'Roo.grid',
1274                                         xtype : 'ColumnModel',
1275                                         header : 'Affected',
1276                                         width : 100,
1277                                         renderer : function(v, x, r) {                     
1278                                                     return v ? String.format('{0}({1})', v,  r.data.on_id)  : '';  
1279                                            },
1280                                         xns : Roo.grid,
1281                                         dataIndex : 'on_table'
1282                                     },
1283 {
1284                                         '|xns' : 'Roo.grid',
1285                                         xtype : 'ColumnModel',
1286                                         header : 'Remarks',
1287                                         width : 300,
1288                                         renderer : function(v) { return String.format('<span qtip="{1}">{0}</span>', v, Roo.util.Format.htmlEncode(v)); },
1289                                         xns : Roo.grid,
1290                                         dataIndex : 'remarks'
1291                                     }
1292                             ],
1293                             listeners : {
1294                                 render : function() { 
1295                                        _this.grid = this; 
1296                                        //_this.dialog = Pman.Dialog.FILL_IN
1297                                        if (_this.panel.active) {
1298                                           this.footer.onClick('first');
1299                                        }
1300                                    }
1301                             },
1302                             items : [
1303
1304                             ]
1305
1306                         },
1307                         '|xns' : 'Roo',
1308                         fitToframe : true,
1309                         background : false,
1310                         region : 'center',
1311                         title : "Events",
1312                         xtype : 'GridPanel',
1313                         fitContainer : true,
1314                         xns : Roo,
1315                         tableName : 'Events',
1316                         listeners : {
1317                                 activate : function() {
1318                                        _this.panel = this;
1319                                        if (_this.grid) {
1320                                            _this.grid.footer.onClick('first');
1321                                        }
1322                                    }
1323                         },
1324                         items : [
1325
1326                         ]
1327
1328                     }
1329                 ]
1330
1331             },
1332             '|xns' : 'Roo',
1333             region : 'center',
1334             xtype : 'NestedLayoutPanel',
1335             title : "Events",
1336             xns : Roo,
1337             items : [
1338
1339             ]
1340
1341         };    }
1342 });