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