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