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