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