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