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