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