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