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