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