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