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