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