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