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