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