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