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