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