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