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