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