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