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