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