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