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