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.dateFrom = _self;
248                                             },
249                                             change : function (_self, newValue, oldValue)
250                                             {
251                                               _this.dategrid.ds.load({});
252                                             }
253                                         },
254                                         format : 'Y-m-d',
255                                         value : (function() { d = new Date(); return d.format('Y-m-01'); })()
256                                     },
257                                     {
258                                         xtype: 'DateField',
259                                         xns: Roo.form,
260                                         listeners : {
261                                             render : function (_self)
262                                             {
263                                               _this.dateTo = _self;
264                                             },
265                                             change : function (_self, newValue, oldValue)
266                                             {
267                                               _this.dategrid.ds.load({});
268                                             }
269                                         },
270                                         format : 'Y-m-d'
271                                     }
272                                 ]
273                             },
274                             colModel : [
275                                 {
276                                     xtype: 'ColumnModel',
277                                     xns: Roo.grid,
278                                     dataIndex : 'person_id_name',
279                                     header : 'Person name',
280                                     sortable : true,
281                                     width : 200,
282                                     renderer : function(v,x,r) {
283                                          return String.format('{0} &lt;<a href="mailto:{1}">{1}</a>&gt;', v, r.data.person_id_email); 
284                                      }
285                                 },
286                                 {
287                                     xtype: 'ColumnModel',
288                                     xns: Roo.grid,
289                                     dataIndex : 'qty',
290                                     header : 'Changes',
291                                     sortable : true,
292                                     width : 70,
293                                     renderer : function(v) { return String.format('{0}', v); }
294                                 }
295                             ]
296                         }
297                     },
298                     {
299                         xtype: 'GridPanel',
300                         xns: Roo,
301                         listeners : {
302                             activate : function() {
303                                 _this.tablepanel = this;
304                                 if (_this.tablegrid) {
305                                     _this.tablegrid.footer.onClick('first');
306                                 }
307                             }
308                         },
309                         background : true,
310                         fitContainer : true,
311                         fitToframe : true,
312                         region : 'center',
313                         tableName : 'Events',
314                         title : "Events",
315                         grid : {
316                             xtype: 'Grid',
317                             xns: Roo.grid,
318                             listeners : {
319                                 render : function() 
320                                 {
321                                     _this.tablegrid = this; 
322                                     //_this.dialog = Pman.Dialog.FILL_IN
323                                     if (_this.tablepanel.active) {
324                                        this.footer.onClick('first');
325                                     }
326                                 },
327                                 rowclick : function (_self, rowIndex, e)
328                                 {
329                                     _this.detailgrid.footer.onClick('first');
330                                 }
331                             },
332                             autoExpandColumn : 'person_name',
333                             loadMask : true,
334                             dataSource : {
335                                 xtype: 'Store',
336                                 xns: Roo.data,
337                                 listeners : {
338                                     beforeload : function (_self, o)
339                                     {
340                                          if (! _this.dategrid) {
341                                          return;
342                                         }
343                                         
344                                         var s = _this.dategrid.selModel.getSelected();
345                                         if (!s) {
346                                             _this.tablegrid.view.el.mask("Select a person");
347                                             return false;
348                                         }
349                                         _this.tablegrid.view.el.unmask();
350                                      
351                                         o.params = o.params || {};
352                                          
353                                      
354                                         act = _this.dateFrom.getValue();
355                                         if (act.format) {
356                                             o.params['query[from]'] = act.format('Y-m-d');
357                                         }
358                                         act = _this.dateTo.getValue();
359                                         if (act.format) {
360                                             o.params['query[to]'] = act.format('Y-m-d');
361                                         }
362                                         o.params.person_id = s.data.person_id;
363                                         o.params['query[table_sum]'] = 1;
364                                         o.params._columns = 'on_table,qty,uqty';
365                                     
366                                         
367                                     }
368                                 },
369                                 remoteSort : true,
370                                 sortInfo : { field : 'on_table', direction: 'ASC' },
371                                 proxy : {
372                                     xtype: 'HttpProxy',
373                                     xns: Roo.data,
374                                     method : 'GET',
375                                     url : baseURL + '/Roo/Events.php'
376                                 },
377                                 reader : {
378                                     xtype: 'JsonReader',
379                                     xns: Roo.data,
380                                     totalProperty : 'total',
381                                     root : 'data',
382                                     id : 'id',
383                                     fields : [
384                                         {
385                                             'name': 'id',
386                                             'type': 'int'
387                                         },
388                                         {
389                                             'name': 'person_name',
390                                             'type': 'string'
391                                         },
392                                         {
393                                             'name': 'event_when',
394                                             'type': 'date',
395                                             'dateFormat': 'Y-m-d'
396                                         },
397                                         {
398                                             'name': 'action',
399                                             'type': 'string'
400                                         },
401                                         {
402                                             'name': 'ipaddr',
403                                             'type': 'string'
404                                         },
405                                         {
406                                             'name': 'on_id',
407                                             'type': 'int'
408                                         },
409                                         {
410                                             'name': 'on_table',
411                                             'type': 'string'
412                                         },
413                                         {
414                                             'name': 'person_id',
415                                             'type': 'int'
416                                         },
417                                         {
418                                             'name': 'remarks',
419                                             'type': 'string'
420                                         },
421                                         {
422                                             'name': 'person_id_id',
423                                             'type': 'int'
424                                         },
425                                         {
426                                             'name': 'person_id_office_id',
427                                             'type': 'int'
428                                         },
429                                         {
430                                             'name': 'person_id_name',
431                                             'type': 'string'
432                                         },
433                                         {
434                                             'name': 'person_id_phone',
435                                             'type': 'string'
436                                         },
437                                         {
438                                             'name': 'person_id_fax',
439                                             'type': 'string'
440                                         },
441                                         {
442                                             'name': 'person_id_email',
443                                             'type': 'string'
444                                         },
445                                         {
446                                             'name': 'person_id_company_id',
447                                             'type': 'int'
448                                         },
449                                         {
450                                             'name': 'person_id_role',
451                                             'type': 'string'
452                                         },
453                                         {
454                                             'name': 'person_id_active',
455                                             'type': 'int'
456                                         },
457                                         {
458                                             'name': 'person_id_remarks',
459                                             'type': 'string'
460                                         },
461                                         {
462                                             'name': 'person_id_passwd',
463                                             'type': 'string'
464                                         },
465                                         {
466                                             'name': 'person_id_owner_id',
467                                             'type': 'int'
468                                         },
469                                         {
470                                             'name': 'person_id_lang',
471                                             'type': 'string'
472                                         },
473                                         {
474                                             'name': 'person_id_no_reset_sent',
475                                             'type': 'int'
476                                         },
477                                         {
478                                             'name': 'person_id_action_type',
479                                             'type': 'string'
480                                         },
481                                         {
482                                             'name': 'person_id_project_id',
483                                             'type': 'int'
484                                         },
485                                         {
486                                             'name': 'person_id_deleted_by',
487                                             'type': 'int'
488                                         },
489                                         {
490                                             'name': 'person_id_deleted_dt',
491                                             'type': 'date'
492                                         }
493                                     ]
494                                 }
495                             },
496                             footer : {
497                                 xtype: 'PagingToolbar',
498                                 xns: Roo,
499                                 pageSize : 25,
500                                 displayInfo : true,
501                                 displayMsg : "Displaying Events{0} - {1} of {2}",
502                                 emptyMsg : "No Events found"
503                             },
504                             toolbar : {
505                                 xtype: 'Toolbar',
506                                 xns: Roo,
507                                 items : [
508                                     {
509                                         xtype: 'ComboBox',
510                                         xns: Roo.form,
511                                         listeners : {
512                                             select : function (combo, record, index)
513                                             {
514                                                _this.dategrid.ds.load({});
515                                             },
516                                             render : function (_self)
517                                             {
518                                               _this.actionSel = _self;
519                                             }
520                                         },
521                                         allowBlank : true,
522                                         displayField : 'action',
523                                         editable : false,
524                                         emptyText : "Select Action",
525                                         forceSelection : true,
526                                         listWidth : 300,
527                                         loadingText : "Searching...",
528                                         minChars : 2,
529                                         name : 'action',
530                                         pageSize : 20,
531                                         qtip : "Select Action",
532                                         queryParam : 'query[action]',
533                                         selectOnFocus : true,
534                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{action}</b> </div>',
535                                         triggerAction : 'all',
536                                         typeAhead : true,
537                                         valueField : 'action',
538                                         width : 150,
539                                         store : {
540                                             xtype: 'Store',
541                                             xns: Roo.data,
542                                             listeners : {
543                                                 beforeload : function (_self, o)
544                                                 {
545                                                     o.params = o.params || {};
546                                                     // staff can see all logs, other companies can only see their own.
547                                                     if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
548                                                         o.params.company_id = Pman.Login.authUser.company_id;
549                                                     }
550                                                     o.params._distinct = 'action';
551                                                     o.params._columns ='action';
552                                                 }
553                                             },
554                                             remoteSort : true,
555                                             sortInfo : { field : 'action' , direction : 'ASC' },
556                                             proxy : {
557                                                 xtype: 'HttpProxy',
558                                                 xns: Roo.data,
559                                                 method : 'GET',
560                                                 url : baseURL + '/Roo/Events.php'
561                                             },
562                                             reader : {
563                                                 xtype: 'JsonReader',
564                                                 xns: Roo.data,
565                                                 totalProperty : 'total',
566                                                 root : 'data',
567                                                 id : 'id',
568                                                 fields : [
569                                                     {
570                                                         'name': 'id',
571                                                         'type': 'int'
572                                                     },
573                                                     {
574                                                         'name': 'person_name',
575                                                         'type': 'string'
576                                                     },
577                                                     {
578                                                         'name': 'event_when',
579                                                         'type': 'date',
580                                                         'dateFormat': 'Y-m-d'
581                                                     },
582                                                     {
583                                                         'name': 'action',
584                                                         'type': 'string'
585                                                     },
586                                                     {
587                                                         'name': 'ipaddr',
588                                                         'type': 'string'
589                                                     },
590                                                     {
591                                                         'name': 'on_id',
592                                                         'type': 'int'
593                                                     },
594                                                     {
595                                                         'name': 'on_table',
596                                                         'type': 'string'
597                                                     },
598                                                     {
599                                                         'name': 'person_id',
600                                                         'type': 'int'
601                                                     },
602                                                     {
603                                                         'name': 'remarks',
604                                                         'type': 'string'
605                                                     },
606                                                     {
607                                                         'name': 'person_id_id',
608                                                         'type': 'int'
609                                                     },
610                                                     {
611                                                         'name': 'person_id_office_id',
612                                                         'type': 'int'
613                                                     },
614                                                     {
615                                                         'name': 'person_id_name',
616                                                         'type': 'string'
617                                                     },
618                                                     {
619                                                         'name': 'person_id_phone',
620                                                         'type': 'string'
621                                                     },
622                                                     {
623                                                         'name': 'person_id_fax',
624                                                         'type': 'string'
625                                                     },
626                                                     {
627                                                         'name': 'person_id_email',
628                                                         'type': 'string'
629                                                     },
630                                                     {
631                                                         'name': 'person_id_company_id',
632                                                         'type': 'int'
633                                                     },
634                                                     {
635                                                         'name': 'person_id_role',
636                                                         'type': 'string'
637                                                     },
638                                                     {
639                                                         'name': 'person_id_active',
640                                                         'type': 'int'
641                                                     },
642                                                     {
643                                                         'name': 'person_id_remarks',
644                                                         'type': 'string'
645                                                     },
646                                                     {
647                                                         'name': 'person_id_passwd',
648                                                         'type': 'string'
649                                                     },
650                                                     {
651                                                         'name': 'person_id_owner_id',
652                                                         'type': 'int'
653                                                     },
654                                                     {
655                                                         'name': 'person_id_lang',
656                                                         'type': 'string'
657                                                     },
658                                                     {
659                                                         'name': 'person_id_no_reset_sent',
660                                                         'type': 'int'
661                                                     },
662                                                     {
663                                                         'name': 'person_id_action_type',
664                                                         'type': 'string'
665                                                     },
666                                                     {
667                                                         'name': 'person_id_project_id',
668                                                         'type': 'int'
669                                                     },
670                                                     {
671                                                         'name': 'person_id_deleted_by',
672                                                         'type': 'int'
673                                                     },
674                                                     {
675                                                         'name': 'person_id_deleted_dt',
676                                                         'type': 'date'
677                                                     }
678                                                 ]
679                                             }
680                                         }
681                                     },
682                                     {
683                                         xtype: 'ComboBox',
684                                         xns: Roo.form,
685                                         listeners : {
686                                             select : function (combo, record, index)
687                                             {
688                                                _this.dategrid.ds.load({});
689                                             },
690                                             render : function (_self)
691                                             {
692                                               _this.affectSel = _self;
693                                             }
694                                         },
695                                         allowBlank : true,
696                                         displayField : 'on_table',
697                                         editable : false,
698                                         emptyText : "Select Affects",
699                                         forceSelection : true,
700                                         listWidth : 300,
701                                         loadingText : "Searching...",
702                                         minChars : 2,
703                                         name : 'on_table',
704                                         pageSize : 20,
705                                         qtip : "Select Action",
706                                         queryParam : 'query[on_table]',
707                                         selectOnFocus : true,
708                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
709                                         triggerAction : 'all',
710                                         typeAhead : true,
711                                         valueField : 'action',
712                                         width : 150,
713                                         store : {
714                                             xtype: 'Store',
715                                             xns: Roo.data,
716                                             listeners : {
717                                                 beforeload : function (_self, o)
718                                                 {
719                                                     o.params = o.params || {};
720                                                     // staff can see all logs, other companies can only see their own.
721                                                     if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
722                                                         o.params.company_id = Pman.Login.authUser.company_id;
723                                                     }
724                                                     o.params._distinct = 'on_table';
725                                                     o.params._columns ='on_table';
726                                                 }
727                                             },
728                                             remoteSort : true,
729                                             sortInfo : { field : 'on_table' , direction : 'ASC' },
730                                             proxy : {
731                                                 xtype: 'HttpProxy',
732                                                 xns: Roo.data,
733                                                 method : 'GET',
734                                                 url : baseURL + '/Roo/Events.php'
735                                             },
736                                             reader : {
737                                                 xtype: 'JsonReader',
738                                                 xns: Roo.data,
739                                                 totalProperty : 'total',
740                                                 root : 'data',
741                                                 id : 'id',
742                                                 fields : [
743                                                     {
744                                                         'name': 'id',
745                                                         'type': 'int'
746                                                     },
747                                                     {
748                                                         'name': 'person_name',
749                                                         'type': 'string'
750                                                     },
751                                                     {
752                                                         'name': 'event_when',
753                                                         'type': 'date',
754                                                         'dateFormat': 'Y-m-d'
755                                                     },
756                                                     {
757                                                         'name': 'action',
758                                                         'type': 'string'
759                                                     },
760                                                     {
761                                                         'name': 'ipaddr',
762                                                         'type': 'string'
763                                                     },
764                                                     {
765                                                         'name': 'on_id',
766                                                         'type': 'int'
767                                                     },
768                                                     {
769                                                         'name': 'on_table',
770                                                         'type': 'string'
771                                                     },
772                                                     {
773                                                         'name': 'person_id',
774                                                         'type': 'int'
775                                                     },
776                                                     {
777                                                         'name': 'remarks',
778                                                         'type': 'string'
779                                                     },
780                                                     {
781                                                         'name': 'person_id_id',
782                                                         'type': 'int'
783                                                     },
784                                                     {
785                                                         'name': 'person_id_office_id',
786                                                         'type': 'int'
787                                                     },
788                                                     {
789                                                         'name': 'person_id_name',
790                                                         'type': 'string'
791                                                     },
792                                                     {
793                                                         'name': 'person_id_phone',
794                                                         'type': 'string'
795                                                     },
796                                                     {
797                                                         'name': 'person_id_fax',
798                                                         'type': 'string'
799                                                     },
800                                                     {
801                                                         'name': 'person_id_email',
802                                                         'type': 'string'
803                                                     },
804                                                     {
805                                                         'name': 'person_id_company_id',
806                                                         'type': 'int'
807                                                     },
808                                                     {
809                                                         'name': 'person_id_role',
810                                                         'type': 'string'
811                                                     },
812                                                     {
813                                                         'name': 'person_id_active',
814                                                         'type': 'int'
815                                                     },
816                                                     {
817                                                         'name': 'person_id_remarks',
818                                                         'type': 'string'
819                                                     },
820                                                     {
821                                                         'name': 'person_id_passwd',
822                                                         'type': 'string'
823                                                     },
824                                                     {
825                                                         'name': 'person_id_owner_id',
826                                                         'type': 'int'
827                                                     },
828                                                     {
829                                                         'name': 'person_id_lang',
830                                                         'type': 'string'
831                                                     },
832                                                     {
833                                                         'name': 'person_id_no_reset_sent',
834                                                         'type': 'int'
835                                                     },
836                                                     {
837                                                         'name': 'person_id_action_type',
838                                                         'type': 'string'
839                                                     },
840                                                     {
841                                                         'name': 'person_id_project_id',
842                                                         'type': 'int'
843                                                     },
844                                                     {
845                                                         'name': 'person_id_deleted_by',
846                                                         'type': 'int'
847                                                     },
848                                                     {
849                                                         'name': 'person_id_deleted_dt',
850                                                         'type': 'date'
851                                                     }
852                                                 ]
853                                             }
854                                         }
855                                     }
856                                 ]
857                             },
858                             colModel : [
859                                 {
860                                     xtype: 'ColumnModel',
861                                     xns: Roo.grid,
862                                     dataIndex : 'on_table',
863                                     header : 'Table',
864                                     sortable : true,
865                                     width : 200,
866                                     renderer : function(v) { return String.format('{0}', v); }
867                                 },
868                                 {
869                                     xtype: 'ColumnModel',
870                                     xns: Roo.grid,
871                                     dataIndex : 'uqty',
872                                     header : '#Affected',
873                                     sortable : true,
874                                     width : 70,
875                                     renderer : function(v) { return String.format('{0}', v); }
876                                 },
877                                 {
878                                     xtype: 'ColumnModel',
879                                     xns: Roo.grid,
880                                     dataIndex : 'qty',
881                                     header : 'Changes',
882                                     sortable : true,
883                                     width : 70,
884                                     renderer : function(v) { return String.format('{0}', v); }
885                                 }
886                             ]
887                         }
888                     },
889                     {
890                         xtype: 'GridPanel',
891                         xns: Roo,
892                         listeners : {
893                             activate : function() {
894                                 _this.detailpanel = this;
895                                 if (_this.detailgrid) {
896                                     _this.detailgrid.footer.onClick('first');
897                                 }
898                             }
899                         },
900                         background : true,
901                         fitContainer : true,
902                         fitToframe : true,
903                         region : 'east',
904                         tableName : 'Events',
905                         title : "Events",
906                         grid : {
907                             xtype: 'Grid',
908                             xns: Roo.grid,
909                             listeners : {
910                                 render : function() 
911                                 {
912                                     _this.detailgrid = this; 
913                                     //_this.dialog = Pman.Dialog.FILL_IN
914                                     if (_this.detailpanel.active) {
915                                        this.footer.onClick('first');
916                                     }
917                                 }
918                             },
919                             autoExpandColumn : 'person_name',
920                             loadMask : true,
921                             dataSource : {
922                                 xtype: 'Store',
923                                 xns: Roo.data,
924                                 listeners : {
925                                     beforeload : function (_self, o)
926                                     {
927                                          if (! _this.dategrid) {
928                                              return false;
929                                         }
930                                         
931                                         o.params = o.params || {};
932                                         
933                                         var s = _this.dategrid.selModel.getSelected();
934                                         if (!s) {
935                                             _this.detailgrid.view.el.mask("Select a person");
936                                             return false;
937                                         }
938                                         
939                                         o.params.person_id = s.data.person_id;    
940                                         
941                                         var s = _this.tablegrid.selModel.getSelected();
942                                         if (!s) {
943                                             _this.detailgrid.view.el.mask("Select a table");
944                                             return false;
945                                         }
946                                         o.params.on_table = s.data.on_table;        
947                                         
948                                         _this.detailgrid.view.el.unmask();
949                                      
950                                     
951                                          
952                                      
953                                         act = _this.dateFrom.getValue();
954                                         if (act.format) {
955                                             o.params['query[from]'] = act.format('Y-m-d');
956                                         }
957                                         act = _this.dateTo.getValue();
958                                         if (act.format) {
959                                             o.params['query[to]'] = act.format('Y-m-d');
960                                         }
961                                     
962                                         //o.params['query[table_d]'] = 1;
963                                         //o.params._columns = 'on_table,qty,uqty';
964                                     
965                                         
966                                     }
967                                 },
968                                 remoteSort : true,
969                                 sortInfo : { field : 'person_name', direction: 'ASC' },
970                                 proxy : {
971                                     xtype: 'HttpProxy',
972                                     xns: Roo.data,
973                                     method : 'GET',
974                                     url : baseURL + '/Roo/Events.php'
975                                 },
976                                 reader : {
977                                     xtype: 'JsonReader',
978                                     xns: Roo.data,
979                                     totalProperty : 'total',
980                                     root : 'data',
981                                     id : 'id',
982                                     fields : [
983                                         {
984                                             'name': 'id',
985                                             'type': 'int'
986                                         },
987                                         {
988                                             'name': 'person_name',
989                                             'type': 'string'
990                                         },
991                                         {
992                                             'name': 'event_when',
993                                             'type': 'date',
994                                             'dateFormat': 'Y-m-d'
995                                         },
996                                         {
997                                             'name': 'action',
998                                             'type': 'string'
999                                         },
1000                                         {
1001                                             'name': 'ipaddr',
1002                                             'type': 'string'
1003                                         },
1004                                         {
1005                                             'name': 'on_id',
1006                                             'type': 'int'
1007                                         },
1008                                         {
1009                                             'name': 'on_table',
1010                                             'type': 'string'
1011                                         },
1012                                         {
1013                                             'name': 'person_id',
1014                                             'type': 'int'
1015                                         },
1016                                         {
1017                                             'name': 'remarks',
1018                                             'type': 'string'
1019                                         },
1020                                         {
1021                                             'name': 'person_id_id',
1022                                             'type': 'int'
1023                                         },
1024                                         {
1025                                             'name': 'person_id_office_id',
1026                                             'type': 'int'
1027                                         },
1028                                         {
1029                                             'name': 'person_id_name',
1030                                             'type': 'string'
1031                                         },
1032                                         {
1033                                             'name': 'person_id_phone',
1034                                             'type': 'string'
1035                                         },
1036                                         {
1037                                             'name': 'person_id_fax',
1038                                             'type': 'string'
1039                                         },
1040                                         {
1041                                             'name': 'person_id_email',
1042                                             'type': 'string'
1043                                         },
1044                                         {
1045                                             'name': 'person_id_company_id',
1046                                             'type': 'int'
1047                                         },
1048                                         {
1049                                             'name': 'person_id_role',
1050                                             'type': 'string'
1051                                         },
1052                                         {
1053                                             'name': 'person_id_active',
1054                                             'type': 'int'
1055                                         },
1056                                         {
1057                                             'name': 'person_id_remarks',
1058                                             'type': 'string'
1059                                         },
1060                                         {
1061                                             'name': 'person_id_passwd',
1062                                             'type': 'string'
1063                                         },
1064                                         {
1065                                             'name': 'person_id_owner_id',
1066                                             'type': 'int'
1067                                         },
1068                                         {
1069                                             'name': 'person_id_lang',
1070                                             'type': 'string'
1071                                         },
1072                                         {
1073                                             'name': 'person_id_no_reset_sent',
1074                                             'type': 'int'
1075                                         },
1076                                         {
1077                                             'name': 'person_id_action_type',
1078                                             'type': 'string'
1079                                         },
1080                                         {
1081                                             'name': 'person_id_project_id',
1082                                             'type': 'int'
1083                                         },
1084                                         {
1085                                             'name': 'person_id_deleted_by',
1086                                             'type': 'int'
1087                                         },
1088                                         {
1089                                             'name': 'person_id_deleted_dt',
1090                                             'type': 'date'
1091                                         }
1092                                     ]
1093                                 }
1094                             },
1095                             footer : {
1096                                 xtype: 'PagingToolbar',
1097                                 xns: Roo,
1098                                 pageSize : 25,
1099                                 displayInfo : true,
1100                                 displayMsg : "Displaying Events{0} - {1} of {2}",
1101                                 emptyMsg : "No Events found"
1102                             },
1103                             colModel : [
1104                                 {
1105                                     xtype: 'ColumnModel',
1106                                     xns: Roo.grid,
1107                                     dataIndex : 'id',
1108                                     header : 'Id',
1109                                     width : 50,
1110                                     renderer : function(v) { return String.format('{0}', v); }
1111                                 },
1112                                 {
1113                                     xtype: 'ColumnModel',
1114                                     xns: Roo.grid,
1115                                     header : 'Event when',
1116                                     width : 75,
1117                                     dataIndex : 'event_when',
1118                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
1119                                 },
1120                                 {
1121                                     xtype: 'ColumnModel',
1122                                     xns: Roo.grid,
1123                                     dataIndex : 'action',
1124                                     header : 'Action',
1125                                     width : 50,
1126                                     renderer : function(v) { return String.format('{0}', v); }
1127                                 },
1128                                 {
1129                                     xtype: 'ColumnModel',
1130                                     xns: Roo.grid,
1131                                     dataIndex : 'ipaddr',
1132                                     header : 'Ipaddr',
1133                                     width : 100,
1134                                     renderer : function(v) { return String.format('{0}', v); }
1135                                 },
1136                                 {
1137                                     xtype: 'ColumnModel',
1138                                     xns: Roo.grid,
1139                                     dataIndex : 'on_id',
1140                                     header : '#ID',
1141                                     width : 75,
1142                                     renderer : function(v) { return String.format('{0}', v); }
1143                                 },
1144                                 {
1145                                     xtype: 'ColumnModel',
1146                                     xns: Roo.grid,
1147                                     header : 'Remarks',
1148                                     width : 200,
1149                                     dataIndex : 'remarks',
1150                                     renderer : function(v) { return String.format('{0}', v); }
1151                                 }
1152                             ]
1153                         }
1154                     }
1155                 ],
1156                 west : {
1157                     xtype: 'LayoutRegion',
1158                     xns: Roo,
1159                     split : true,
1160                     width : 270
1161                 },
1162                 center : {
1163                     xtype: 'LayoutRegion',
1164                     xns: Roo
1165                 },
1166                 east : {
1167                     xtype: 'LayoutRegion',
1168                     xns: Roo,
1169                     split : true,
1170                     width : 600
1171                 }
1172             }
1173         });
1174         this.layout = this.panel.layout;
1175
1176     }
1177 });