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