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