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             },
240             layout : {
241                 xtype: 'BorderLayout',
242                 xns: Roo,
243                 items : [
244                     {
245                         xtype: 'GridPanel',
246                         xns: Roo,
247                         listeners : {
248                             activate : function() {
249                                 _this.datepanel = this;
250                                 if (_this.dategrid) {
251                                     _this.dategrid.ds.load({});
252                                 }
253                             }
254                         },
255                         background : false,
256                         fitContainer : true,
257                         fitToframe : true,
258                         region : 'west',
259                         tableName : 'Events',
260                         title : "Events",
261                         grid : {
262                             xtype: 'Grid',
263                             xns: Roo.grid,
264                             listeners : {
265                                 render : function() 
266                                 {
267                                     _this.dategrid = this; 
268                                     //_this.dialog = Pman.Dialog.FILL_IN
269                                     if (_this.panel.active) {
270                                        this.ds.load({});
271                                     }
272                                 },
273                                 rowclick : function (_self, rowIndex, e)
274                                 {
275                                     _this.tablegrid.footer.onClick('first');
276                                 }
277                             },
278                             autoExpandColumn : 'person_name',
279                             loadMask : true,
280                             dataSource : {
281                                 xtype: 'Store',
282                                 xns: Roo.data,
283                                 listeners : {
284                                     beforeload : function (_self, o)
285                                     {
286                                         
287                                         
288                                         if (! _this.dateFrom) {
289                                             return;
290                                         }
291                                     
292                                          try {
293                                              _this.tablegrid.ds.removeAll();
294                                              _this.panel.layout.getRegion('east').getActivePanel().grid.ds.removeAll();
295                                              
296                                         } catch (e) {
297                                             // do nothing..
298                                         }
299                                         o.params = o.params || {};
300                                          
301                                         var act = _this.actionSel ? _this.actionSel.getValue() : '';
302                                         if (act.length) {
303                                             o.params.action = act;
304                                         }
305                                         var tbl = _this.affectSel ? _this.affectSel.getValue() : '';
306                                         if (tbl.length) {
307                                             o.params.on_table = tbl;
308                                         }
309                                         act = _this.dateFrom.getValue();
310                                         if (act.format) {
311                                             o.params['query[from]'] = act.format('Y-m-d');
312                                         }
313                                         act = _this.dateTo.getValue();
314                                         if (act.format) {
315                                             o.params['query[to]'] = act.format('Y-m-d');
316                                         }
317                                         
318                                         
319                                         
320                                         o.params['query[person_sum]'] = 1;
321                                         o.params._columns = 'person_id,person_id_name,person_id_email,qty,uqty';
322                                         o.params.limit = 999;
323                                      
324                                     }
325                                 },
326                                 remoteSort : true,
327                                 sortInfo : { field : 'person_name', direction: 'ASC' },
328                                 proxy : {
329                                     xtype: 'HttpProxy',
330                                     xns: Roo.data,
331                                     method : 'GET',
332                                     url : baseURL + '/Roo/Events.php'
333                                 },
334                                 reader : {
335                                     xtype: 'JsonReader',
336                                     xns: Roo.data,
337                                     totalProperty : 'total',
338                                     root : 'data',
339                                     id : 'id',
340                                     fields : [
341                                         {
342                                             'name': 'id',
343                                             'type': 'int'
344                                         },
345                                         {
346                                             'name': 'person_name',
347                                             'type': 'string'
348                                         },
349                                         {
350                                             'name': 'event_when',
351                                             'type': 'date',
352                                             'dateFormat': 'Y-m-d'
353                                         },
354                                         {
355                                             'name': 'action',
356                                             'type': 'string'
357                                         },
358                                         {
359                                             'name': 'ipaddr',
360                                             'type': 'string'
361                                         },
362                                         {
363                                             'name': 'on_id',
364                                             'type': 'int'
365                                         },
366                                         {
367                                             'name': 'on_table',
368                                             'type': 'string'
369                                         },
370                                         {
371                                             'name': 'person_id',
372                                             'type': 'int'
373                                         },
374                                         {
375                                             'name': 'remarks',
376                                             'type': 'string'
377                                         },
378                                         {
379                                             'name': 'person_id_id',
380                                             'type': 'int'
381                                         },
382                                         {
383                                             'name': 'person_id_office_id',
384                                             'type': 'int'
385                                         },
386                                         {
387                                             'name': 'person_id_name',
388                                             'type': 'string'
389                                         },
390                                         {
391                                             'name': 'person_id_phone',
392                                             'type': 'string'
393                                         },
394                                         {
395                                             'name': 'person_id_fax',
396                                             'type': 'string'
397                                         },
398                                         {
399                                             'name': 'person_id_email',
400                                             'type': 'string'
401                                         },
402                                         {
403                                             'name': 'person_id_company_id',
404                                             'type': 'int'
405                                         },
406                                         {
407                                             'name': 'person_id_role',
408                                             'type': 'string'
409                                         },
410                                         {
411                                             'name': 'person_id_active',
412                                             'type': 'int'
413                                         },
414                                         {
415                                             'name': 'person_id_remarks',
416                                             'type': 'string'
417                                         },
418                                         {
419                                             'name': 'person_id_passwd',
420                                             'type': 'string'
421                                         },
422                                         {
423                                             'name': 'person_id_owner_id',
424                                             'type': 'int'
425                                         },
426                                         {
427                                             'name': 'person_id_lang',
428                                             'type': 'string'
429                                         },
430                                         {
431                                             'name': 'person_id_no_reset_sent',
432                                             'type': 'int'
433                                         },
434                                         {
435                                             'name': 'person_id_action_type',
436                                             'type': 'string'
437                                         },
438                                         {
439                                             'name': 'person_id_project_id',
440                                             'type': 'int'
441                                         },
442                                         {
443                                             'name': 'person_id_deleted_by',
444                                             'type': 'int'
445                                         },
446                                         {
447                                             'name': 'person_id_deleted_dt',
448                                             'type': 'date'
449                                         }
450                                     ]
451                                 }
452                             },
453                             colModel : [
454                                 {
455                                     xtype: 'ColumnModel',
456                                     xns: Roo.grid,
457                                     dataIndex : 'person_id_name',
458                                     header : 'Person name',
459                                     sortable : true,
460                                     width : 200,
461                                     renderer : function(v,x,r) {
462                                          return String.format('{0} &lt;<a href="mailto:{1}">{1}</a>&gt;', v, r.data.person_id_email); 
463                                      }
464                                 },
465                                 {
466                                     xtype: 'ColumnModel',
467                                     xns: Roo.grid,
468                                     dataIndex : 'uqty',
469                                     header : '#Affected',
470                                     sortable : true,
471                                     width : 70,
472                                     renderer : function(v) { return String.format('{0}', v); }
473                                 },
474                                 {
475                                     xtype: 'ColumnModel',
476                                     xns: Roo.grid,
477                                     dataIndex : 'qty',
478                                     header : 'Changes',
479                                     sortable : true,
480                                     width : 70,
481                                     renderer : function(v) { return String.format('{0}', v); }
482                                 }
483                             ]
484                         }
485                     },
486                     {
487                         xtype: 'GridPanel',
488                         xns: Roo,
489                         listeners : {
490                             activate : function() {
491                                 _this.tablepanel = this;
492                                 if (_this.tablegrid) {
493                                     _this.tablegrid.footer.onClick('first');
494                                 }
495                             }
496                         },
497                         background : false,
498                         fitContainer : true,
499                         fitToframe : true,
500                         region : 'center',
501                         tableName : 'Events',
502                         title : "Events",
503                         grid : {
504                             xtype: 'Grid',
505                             xns: Roo.grid,
506                             listeners : {
507                                 render : function() 
508                                 {
509                                     _this.tablegrid = this; 
510                                     //_this.dialog = Pman.Dialog.FILL_IN
511                                     if (_this.tablepanel.active) {
512                                        this.footer.onClick('first');
513                                     }
514                                 },
515                                 rowclick : function (_self, rowIndex, e)
516                                 {
517                                  
518                                     _this.panel.layout.getRegion('east').getActivePanel().grid.footer.onClick('first');
519                                 }
520                             },
521                             autoExpandColumn : 'person_name',
522                             loadMask : true,
523                             dataSource : {
524                                 xtype: 'Store',
525                                 xns: Roo.data,
526                                 listeners : {
527                                     beforeload : function (_self, o)
528                                     {
529                                          if (! _this.dategrid) {
530                                          return;
531                                         }
532                                         try {
533                                              _this.panel.layout.getRegion('east').getActivePanel().grid.ds.removeAll();
534                                              
535                                         } catch (e) {
536                                             // do nothing..
537                                         }
538                                         
539                                         var s = _this.dategrid.selModel.getSelected();
540                                         if (!s) {
541                                             _this.tablegrid.view.el.mask("Select a person");
542                                             return false;
543                                         }
544                                         _this.tablegrid.view.el.unmask();
545                                      
546                                         o.params = o.params || {};
547                                         var act = _this.actionSel.getValue();
548                                         if (act.length) {
549                                             o.params.action = act;
550                                         }
551                                         var tbl = _this.affectSel.getValue();
552                                         if (tbl.length) {
553                                             o.params.on_table = tbl;
554                                         }
555                                      
556                                         act = _this.dateFrom.getValue();
557                                         if (act.format) {
558                                             o.params['query[from]'] = act.format('Y-m-d');
559                                         }
560                                         act = _this.dateTo.getValue();
561                                         if (act.format) {
562                                             o.params['query[to]'] = act.format('Y-m-d');
563                                         }
564                                         o.params.person_id = s.data.person_id;
565                                         o.params['query[table_sum]'] = 1;
566                                         o.params._columns = 'on_table,qty,uqty';
567                                     
568                                         
569                                     }
570                                 },
571                                 remoteSort : true,
572                                 sortInfo : { field : 'on_table', direction: 'ASC' },
573                                 proxy : {
574                                     xtype: 'HttpProxy',
575                                     xns: Roo.data,
576                                     method : 'GET',
577                                     url : baseURL + '/Roo/Events.php'
578                                 },
579                                 reader : {
580                                     xtype: 'JsonReader',
581                                     xns: Roo.data,
582                                     totalProperty : 'total',
583                                     root : 'data',
584                                     id : 'id',
585                                     fields : [
586                                         {
587                                             'name': 'id',
588                                             'type': 'int'
589                                         },
590                                         {
591                                             'name': 'person_name',
592                                             'type': 'string'
593                                         },
594                                         {
595                                             'name': 'event_when',
596                                             'type': 'date',
597                                             'dateFormat': 'Y-m-d'
598                                         },
599                                         {
600                                             'name': 'action',
601                                             'type': 'string'
602                                         },
603                                         {
604                                             'name': 'ipaddr',
605                                             'type': 'string'
606                                         },
607                                         {
608                                             'name': 'on_id',
609                                             'type': 'int'
610                                         },
611                                         {
612                                             'name': 'on_table',
613                                             'type': 'string'
614                                         },
615                                         {
616                                             'name': 'person_id',
617                                             'type': 'int'
618                                         },
619                                         {
620                                             'name': 'remarks',
621                                             'type': 'string'
622                                         },
623                                         {
624                                             'name': 'person_id_id',
625                                             'type': 'int'
626                                         },
627                                         {
628                                             'name': 'person_id_office_id',
629                                             'type': 'int'
630                                         },
631                                         {
632                                             'name': 'person_id_name',
633                                             'type': 'string'
634                                         },
635                                         {
636                                             'name': 'person_id_phone',
637                                             'type': 'string'
638                                         },
639                                         {
640                                             'name': 'person_id_fax',
641                                             'type': 'string'
642                                         },
643                                         {
644                                             'name': 'person_id_email',
645                                             'type': 'string'
646                                         },
647                                         {
648                                             'name': 'person_id_company_id',
649                                             'type': 'int'
650                                         },
651                                         {
652                                             'name': 'person_id_role',
653                                             'type': 'string'
654                                         },
655                                         {
656                                             'name': 'person_id_active',
657                                             'type': 'int'
658                                         },
659                                         {
660                                             'name': 'person_id_remarks',
661                                             'type': 'string'
662                                         },
663                                         {
664                                             'name': 'person_id_passwd',
665                                             'type': 'string'
666                                         },
667                                         {
668                                             'name': 'person_id_owner_id',
669                                             'type': 'int'
670                                         },
671                                         {
672                                             'name': 'person_id_lang',
673                                             'type': 'string'
674                                         },
675                                         {
676                                             'name': 'person_id_no_reset_sent',
677                                             'type': 'int'
678                                         },
679                                         {
680                                             'name': 'person_id_action_type',
681                                             'type': 'string'
682                                         },
683                                         {
684                                             'name': 'person_id_project_id',
685                                             'type': 'int'
686                                         },
687                                         {
688                                             'name': 'person_id_deleted_by',
689                                             'type': 'int'
690                                         },
691                                         {
692                                             'name': 'person_id_deleted_dt',
693                                             'type': 'date'
694                                         }
695                                     ]
696                                 }
697                             },
698                             footer : {
699                                 xtype: 'PagingToolbar',
700                                 xns: Roo,
701                                 pageSize : 25,
702                                 displayInfo : true,
703                                 displayMsg : "Displaying Events{0} - {1} of {2}",
704                                 emptyMsg : "No Events found"
705                             },
706                             toolbar : {
707                                 xtype: 'Toolbar',
708                                 xns: Roo,
709                                 items : [
710                                     {
711                                         xtype: 'ComboBox',
712                                         xns: Roo.form,
713                                         listeners : {
714                                             select : function (combo, record, index)
715                                             {
716                                                _this.dategrid.ds.load({});
717                                             },
718                                             render : function (_self)
719                                             {
720                                               _this.actionSel = _self;
721                                             }
722                                         },
723                                         allowBlank : true,
724                                         displayField : 'action',
725                                         editable : false,
726                                         emptyText : "Select Action",
727                                         forceSelection : true,
728                                         listWidth : 300,
729                                         loadingText : "Searching...",
730                                         minChars : 2,
731                                         name : 'action',
732                                         pageSize : 20,
733                                         qtip : "Select Action",
734                                         queryParam : 'query[action]',
735                                         selectOnFocus : true,
736                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{action}</b> </div>',
737                                         triggerAction : 'all',
738                                         typeAhead : true,
739                                         valueField : 'action',
740                                         width : 150,
741                                         store : {
742                                             xtype: 'Store',
743                                             xns: Roo.data,
744                                             listeners : {
745                                                 beforeload : function (_self, o)
746                                                 {
747                                                     o.params = o.params || {};
748                                                     // staff can see all logs, other companies can only see their own.
749                                                     if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
750                                                         o.params.company_id = Pman.Login.authUser.company_id;
751                                                     }
752                                                     o.params._distinct = 'action';
753                                                     o.params._columns ='action';
754                                                 }
755                                             },
756                                             remoteSort : true,
757                                             sortInfo : { field : 'action' , direction : 'ASC' },
758                                             proxy : {
759                                                 xtype: 'HttpProxy',
760                                                 xns: Roo.data,
761                                                 method : 'GET',
762                                                 url : baseURL + '/Roo/Events.php'
763                                             },
764                                             reader : {
765                                                 xtype: 'JsonReader',
766                                                 xns: Roo.data,
767                                                 totalProperty : 'total',
768                                                 root : 'data',
769                                                 id : 'id',
770                                                 fields : [
771                                                     {
772                                                         'name': 'id',
773                                                         'type': 'int'
774                                                     },
775                                                     {
776                                                         'name': 'person_name',
777                                                         'type': 'string'
778                                                     },
779                                                     {
780                                                         'name': 'event_when',
781                                                         'type': 'date',
782                                                         'dateFormat': 'Y-m-d'
783                                                     },
784                                                     {
785                                                         'name': 'action',
786                                                         'type': 'string'
787                                                     },
788                                                     {
789                                                         'name': 'ipaddr',
790                                                         'type': 'string'
791                                                     },
792                                                     {
793                                                         'name': 'on_id',
794                                                         'type': 'int'
795                                                     },
796                                                     {
797                                                         'name': 'on_table',
798                                                         'type': 'string'
799                                                     },
800                                                     {
801                                                         'name': 'person_id',
802                                                         'type': 'int'
803                                                     },
804                                                     {
805                                                         'name': 'remarks',
806                                                         'type': 'string'
807                                                     },
808                                                     {
809                                                         'name': 'person_id_id',
810                                                         'type': 'int'
811                                                     },
812                                                     {
813                                                         'name': 'person_id_office_id',
814                                                         'type': 'int'
815                                                     },
816                                                     {
817                                                         'name': 'person_id_name',
818                                                         'type': 'string'
819                                                     },
820                                                     {
821                                                         'name': 'person_id_phone',
822                                                         'type': 'string'
823                                                     },
824                                                     {
825                                                         'name': 'person_id_fax',
826                                                         'type': 'string'
827                                                     },
828                                                     {
829                                                         'name': 'person_id_email',
830                                                         'type': 'string'
831                                                     },
832                                                     {
833                                                         'name': 'person_id_company_id',
834                                                         'type': 'int'
835                                                     },
836                                                     {
837                                                         'name': 'person_id_role',
838                                                         'type': 'string'
839                                                     },
840                                                     {
841                                                         'name': 'person_id_active',
842                                                         'type': 'int'
843                                                     },
844                                                     {
845                                                         'name': 'person_id_remarks',
846                                                         'type': 'string'
847                                                     },
848                                                     {
849                                                         'name': 'person_id_passwd',
850                                                         'type': 'string'
851                                                     },
852                                                     {
853                                                         'name': 'person_id_owner_id',
854                                                         'type': 'int'
855                                                     },
856                                                     {
857                                                         'name': 'person_id_lang',
858                                                         'type': 'string'
859                                                     },
860                                                     {
861                                                         'name': 'person_id_no_reset_sent',
862                                                         'type': 'int'
863                                                     },
864                                                     {
865                                                         'name': 'person_id_action_type',
866                                                         'type': 'string'
867                                                     },
868                                                     {
869                                                         'name': 'person_id_project_id',
870                                                         'type': 'int'
871                                                     },
872                                                     {
873                                                         'name': 'person_id_deleted_by',
874                                                         'type': 'int'
875                                                     },
876                                                     {
877                                                         'name': 'person_id_deleted_dt',
878                                                         'type': 'date'
879                                                     }
880                                                 ]
881                                             }
882                                         }
883                                     },
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 });