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