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