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