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