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