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