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