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