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