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