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