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