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                                  
341                                     _this.panel.layout.getRegion('east').getActivePanel().grid.footer.onClick('first');
342                                 }
343                             },
344                             autoExpandColumn : 'person_name',
345                             loadMask : true,
346                             dataSource : {
347                                 xtype: 'Store',
348                                 xns: Roo.data,
349                                 listeners : {
350                                     beforeload : function (_self, o)
351                                     {
352                                          if (! _this.dategrid) {
353                                          return;
354                                         }
355                                         
356                                         var s = _this.dategrid.selModel.getSelected();
357                                         if (!s) {
358                                             _this.tablegrid.view.el.mask("Select a person");
359                                             return false;
360                                         }
361                                         _this.tablegrid.view.el.unmask();
362                                      
363                                         o.params = o.params || {};
364                                         var act = _this.actionSel.getValue();
365                                         if (act.length) {
366                                             o.params.action = act;
367                                         }
368                                         var tbl = _this.affectSel.getValue();
369                                         if (tbl.length) {
370                                             o.params.on_table = tbl;
371                                         }
372                                      
373                                         act = _this.dateFrom.getValue();
374                                         if (act.format) {
375                                             o.params['query[from]'] = act.format('Y-m-d');
376                                         }
377                                         act = _this.dateTo.getValue();
378                                         if (act.format) {
379                                             o.params['query[to]'] = act.format('Y-m-d');
380                                         }
381                                         o.params.person_id = s.data.person_id;
382                                         o.params['query[table_sum]'] = 1;
383                                         o.params._columns = 'on_table,qty,uqty';
384                                     
385                                         
386                                     }
387                                 },
388                                 remoteSort : true,
389                                 sortInfo : { field : 'on_table', direction: 'ASC' },
390                                 proxy : {
391                                     xtype: 'HttpProxy',
392                                     xns: Roo.data,
393                                     method : 'GET',
394                                     url : baseURL + '/Roo/Events.php'
395                                 },
396                                 reader : {
397                                     xtype: 'JsonReader',
398                                     xns: Roo.data,
399                                     totalProperty : 'total',
400                                     root : 'data',
401                                     id : 'id',
402                                     fields : [
403                                         {
404                                             'name': 'id',
405                                             'type': 'int'
406                                         },
407                                         {
408                                             'name': 'person_name',
409                                             'type': 'string'
410                                         },
411                                         {
412                                             'name': 'event_when',
413                                             'type': 'date',
414                                             'dateFormat': 'Y-m-d'
415                                         },
416                                         {
417                                             'name': 'action',
418                                             'type': 'string'
419                                         },
420                                         {
421                                             'name': 'ipaddr',
422                                             'type': 'string'
423                                         },
424                                         {
425                                             'name': 'on_id',
426                                             'type': 'int'
427                                         },
428                                         {
429                                             'name': 'on_table',
430                                             'type': 'string'
431                                         },
432                                         {
433                                             'name': 'person_id',
434                                             'type': 'int'
435                                         },
436                                         {
437                                             'name': 'remarks',
438                                             'type': 'string'
439                                         },
440                                         {
441                                             'name': 'person_id_id',
442                                             'type': 'int'
443                                         },
444                                         {
445                                             'name': 'person_id_office_id',
446                                             'type': 'int'
447                                         },
448                                         {
449                                             'name': 'person_id_name',
450                                             'type': 'string'
451                                         },
452                                         {
453                                             'name': 'person_id_phone',
454                                             'type': 'string'
455                                         },
456                                         {
457                                             'name': 'person_id_fax',
458                                             'type': 'string'
459                                         },
460                                         {
461                                             'name': 'person_id_email',
462                                             'type': 'string'
463                                         },
464                                         {
465                                             'name': 'person_id_company_id',
466                                             'type': 'int'
467                                         },
468                                         {
469                                             'name': 'person_id_role',
470                                             'type': 'string'
471                                         },
472                                         {
473                                             'name': 'person_id_active',
474                                             'type': 'int'
475                                         },
476                                         {
477                                             'name': 'person_id_remarks',
478                                             'type': 'string'
479                                         },
480                                         {
481                                             'name': 'person_id_passwd',
482                                             'type': 'string'
483                                         },
484                                         {
485                                             'name': 'person_id_owner_id',
486                                             'type': 'int'
487                                         },
488                                         {
489                                             'name': 'person_id_lang',
490                                             'type': 'string'
491                                         },
492                                         {
493                                             'name': 'person_id_no_reset_sent',
494                                             'type': 'int'
495                                         },
496                                         {
497                                             'name': 'person_id_action_type',
498                                             'type': 'string'
499                                         },
500                                         {
501                                             'name': 'person_id_project_id',
502                                             'type': 'int'
503                                         },
504                                         {
505                                             'name': 'person_id_deleted_by',
506                                             'type': 'int'
507                                         },
508                                         {
509                                             'name': 'person_id_deleted_dt',
510                                             'type': 'date'
511                                         }
512                                     ]
513                                 }
514                             },
515                             footer : {
516                                 xtype: 'PagingToolbar',
517                                 xns: Roo,
518                                 pageSize : 25,
519                                 displayInfo : true,
520                                 displayMsg : "Displaying Events{0} - {1} of {2}",
521                                 emptyMsg : "No Events found"
522                             },
523                             toolbar : {
524                                 xtype: 'Toolbar',
525                                 xns: Roo,
526                                 items : [
527                                     {
528                                         xtype: 'ComboBox',
529                                         xns: Roo.form,
530                                         listeners : {
531                                             select : function (combo, record, index)
532                                             {
533                                                _this.dategrid.ds.load({});
534                                             },
535                                             render : function (_self)
536                                             {
537                                               _this.actionSel = _self;
538                                             }
539                                         },
540                                         allowBlank : true,
541                                         displayField : 'action',
542                                         editable : false,
543                                         emptyText : "Select Action",
544                                         forceSelection : true,
545                                         listWidth : 300,
546                                         loadingText : "Searching...",
547                                         minChars : 2,
548                                         name : 'action',
549                                         pageSize : 20,
550                                         qtip : "Select Action",
551                                         queryParam : 'query[action]',
552                                         selectOnFocus : true,
553                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{action}</b> </div>',
554                                         triggerAction : 'all',
555                                         typeAhead : true,
556                                         valueField : 'action',
557                                         width : 150,
558                                         store : {
559                                             xtype: 'Store',
560                                             xns: Roo.data,
561                                             listeners : {
562                                                 beforeload : function (_self, o)
563                                                 {
564                                                     o.params = o.params || {};
565                                                     // staff can see all logs, other companies can only see their own.
566                                                     if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
567                                                         o.params.company_id = Pman.Login.authUser.company_id;
568                                                     }
569                                                     o.params._distinct = 'action';
570                                                     o.params._columns ='action';
571                                                 }
572                                             },
573                                             remoteSort : true,
574                                             sortInfo : { field : 'action' , direction : 'ASC' },
575                                             proxy : {
576                                                 xtype: 'HttpProxy',
577                                                 xns: Roo.data,
578                                                 method : 'GET',
579                                                 url : baseURL + '/Roo/Events.php'
580                                             },
581                                             reader : {
582                                                 xtype: 'JsonReader',
583                                                 xns: Roo.data,
584                                                 totalProperty : 'total',
585                                                 root : 'data',
586                                                 id : 'id',
587                                                 fields : [
588                                                     {
589                                                         'name': 'id',
590                                                         'type': 'int'
591                                                     },
592                                                     {
593                                                         'name': 'person_name',
594                                                         'type': 'string'
595                                                     },
596                                                     {
597                                                         'name': 'event_when',
598                                                         'type': 'date',
599                                                         'dateFormat': 'Y-m-d'
600                                                     },
601                                                     {
602                                                         'name': 'action',
603                                                         'type': 'string'
604                                                     },
605                                                     {
606                                                         'name': 'ipaddr',
607                                                         'type': 'string'
608                                                     },
609                                                     {
610                                                         'name': 'on_id',
611                                                         'type': 'int'
612                                                     },
613                                                     {
614                                                         'name': 'on_table',
615                                                         'type': 'string'
616                                                     },
617                                                     {
618                                                         'name': 'person_id',
619                                                         'type': 'int'
620                                                     },
621                                                     {
622                                                         'name': 'remarks',
623                                                         'type': 'string'
624                                                     },
625                                                     {
626                                                         'name': 'person_id_id',
627                                                         'type': 'int'
628                                                     },
629                                                     {
630                                                         'name': 'person_id_office_id',
631                                                         'type': 'int'
632                                                     },
633                                                     {
634                                                         'name': 'person_id_name',
635                                                         'type': 'string'
636                                                     },
637                                                     {
638                                                         'name': 'person_id_phone',
639                                                         'type': 'string'
640                                                     },
641                                                     {
642                                                         'name': 'person_id_fax',
643                                                         'type': 'string'
644                                                     },
645                                                     {
646                                                         'name': 'person_id_email',
647                                                         'type': 'string'
648                                                     },
649                                                     {
650                                                         'name': 'person_id_company_id',
651                                                         'type': 'int'
652                                                     },
653                                                     {
654                                                         'name': 'person_id_role',
655                                                         'type': 'string'
656                                                     },
657                                                     {
658                                                         'name': 'person_id_active',
659                                                         'type': 'int'
660                                                     },
661                                                     {
662                                                         'name': 'person_id_remarks',
663                                                         'type': 'string'
664                                                     },
665                                                     {
666                                                         'name': 'person_id_passwd',
667                                                         'type': 'string'
668                                                     },
669                                                     {
670                                                         'name': 'person_id_owner_id',
671                                                         'type': 'int'
672                                                     },
673                                                     {
674                                                         'name': 'person_id_lang',
675                                                         'type': 'string'
676                                                     },
677                                                     {
678                                                         'name': 'person_id_no_reset_sent',
679                                                         'type': 'int'
680                                                     },
681                                                     {
682                                                         'name': 'person_id_action_type',
683                                                         'type': 'string'
684                                                     },
685                                                     {
686                                                         'name': 'person_id_project_id',
687                                                         'type': 'int'
688                                                     },
689                                                     {
690                                                         'name': 'person_id_deleted_by',
691                                                         'type': 'int'
692                                                     },
693                                                     {
694                                                         'name': 'person_id_deleted_dt',
695                                                         'type': 'date'
696                                                     }
697                                                 ]
698                                             }
699                                         }
700                                     },
701                                     {
702                                         xtype: 'ComboBox',
703                                         xns: Roo.form,
704                                         listeners : {
705                                             select : function (combo, record, index)
706                                             {
707                                                _this.dategrid.ds.load({});
708                                             },
709                                             render : function (_self)
710                                             {
711                                               _this.affectSel = _self;
712                                             }
713                                         },
714                                         allowBlank : true,
715                                         displayField : 'on_table',
716                                         editable : false,
717                                         emptyText : "Select Affects",
718                                         forceSelection : true,
719                                         listWidth : 300,
720                                         loadingText : "Searching...",
721                                         minChars : 2,
722                                         name : 'on_table',
723                                         pageSize : 20,
724                                         qtip : "Select Action",
725                                         queryParam : 'query[on_table]',
726                                         selectOnFocus : true,
727                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{on_table}</b> </div>',
728                                         triggerAction : 'all',
729                                         typeAhead : true,
730                                         valueField : 'action',
731                                         width : 150,
732                                         store : {
733                                             xtype: 'Store',
734                                             xns: Roo.data,
735                                             listeners : {
736                                                 beforeload : function (_self, o)
737                                                 {
738                                                     o.params = o.params || {};
739                                                     // staff can see all logs, other companies can only see their own.
740                                                     if (Pman.Login.authUser.company_id_comptype != 'OWNER') {
741                                                         o.params.company_id = Pman.Login.authUser.company_id;
742                                                     }
743                                                     o.params._distinct = 'on_table';
744                                                     o.params._columns ='on_table';
745                                                 }
746                                             },
747                                             remoteSort : true,
748                                             sortInfo : { field : 'on_table' , direction : 'ASC' },
749                                             proxy : {
750                                                 xtype: 'HttpProxy',
751                                                 xns: Roo.data,
752                                                 method : 'GET',
753                                                 url : baseURL + '/Roo/Events.php'
754                                             },
755                                             reader : {
756                                                 xtype: 'JsonReader',
757                                                 xns: Roo.data,
758                                                 totalProperty : 'total',
759                                                 root : 'data',
760                                                 id : 'id',
761                                                 fields : [
762                                                     {
763                                                         'name': 'id',
764                                                         'type': 'int'
765                                                     },
766                                                     {
767                                                         'name': 'person_name',
768                                                         'type': 'string'
769                                                     },
770                                                     {
771                                                         'name': 'event_when',
772                                                         'type': 'date',
773                                                         'dateFormat': 'Y-m-d'
774                                                     },
775                                                     {
776                                                         'name': 'action',
777                                                         'type': 'string'
778                                                     },
779                                                     {
780                                                         'name': 'ipaddr',
781                                                         'type': 'string'
782                                                     },
783                                                     {
784                                                         'name': 'on_id',
785                                                         'type': 'int'
786                                                     },
787                                                     {
788                                                         'name': 'on_table',
789                                                         'type': 'string'
790                                                     },
791                                                     {
792                                                         'name': 'person_id',
793                                                         'type': 'int'
794                                                     },
795                                                     {
796                                                         'name': 'remarks',
797                                                         'type': 'string'
798                                                     },
799                                                     {
800                                                         'name': 'person_id_id',
801                                                         'type': 'int'
802                                                     },
803                                                     {
804                                                         'name': 'person_id_office_id',
805                                                         'type': 'int'
806                                                     },
807                                                     {
808                                                         'name': 'person_id_name',
809                                                         'type': 'string'
810                                                     },
811                                                     {
812                                                         'name': 'person_id_phone',
813                                                         'type': 'string'
814                                                     },
815                                                     {
816                                                         'name': 'person_id_fax',
817                                                         'type': 'string'
818                                                     },
819                                                     {
820                                                         'name': 'person_id_email',
821                                                         'type': 'string'
822                                                     },
823                                                     {
824                                                         'name': 'person_id_company_id',
825                                                         'type': 'int'
826                                                     },
827                                                     {
828                                                         'name': 'person_id_role',
829                                                         'type': 'string'
830                                                     },
831                                                     {
832                                                         'name': 'person_id_active',
833                                                         'type': 'int'
834                                                     },
835                                                     {
836                                                         'name': 'person_id_remarks',
837                                                         'type': 'string'
838                                                     },
839                                                     {
840                                                         'name': 'person_id_passwd',
841                                                         'type': 'string'
842                                                     },
843                                                     {
844                                                         'name': 'person_id_owner_id',
845                                                         'type': 'int'
846                                                     },
847                                                     {
848                                                         'name': 'person_id_lang',
849                                                         'type': 'string'
850                                                     },
851                                                     {
852                                                         'name': 'person_id_no_reset_sent',
853                                                         'type': 'int'
854                                                     },
855                                                     {
856                                                         'name': 'person_id_action_type',
857                                                         'type': 'string'
858                                                     },
859                                                     {
860                                                         'name': 'person_id_project_id',
861                                                         'type': 'int'
862                                                     },
863                                                     {
864                                                         'name': 'person_id_deleted_by',
865                                                         'type': 'int'
866                                                     },
867                                                     {
868                                                         'name': 'person_id_deleted_dt',
869                                                         'type': 'date'
870                                                     }
871                                                 ]
872                                             }
873                                         }
874                                     }
875                                 ]
876                             },
877                             colModel : [
878                                 {
879                                     xtype: 'ColumnModel',
880                                     xns: Roo.grid,
881                                     dataIndex : 'on_table',
882                                     header : 'Table',
883                                     sortable : true,
884                                     width : 200,
885                                     renderer : function(v) { return String.format('{0}', v); }
886                                 },
887                                 {
888                                     xtype: 'ColumnModel',
889                                     xns: Roo.grid,
890                                     dataIndex : 'uqty',
891                                     header : '#Affected',
892                                     sortable : true,
893                                     width : 70,
894                                     renderer : function(v) { return String.format('{0}', v); }
895                                 },
896                                 {
897                                     xtype: 'ColumnModel',
898                                     xns: Roo.grid,
899                                     dataIndex : 'qty',
900                                     header : 'Changes',
901                                     sortable : true,
902                                     width : 70,
903                                     renderer : function(v) { return String.format('{0}', v); }
904                                 }
905                             ]
906                         }
907                     },
908                     {
909                         xtype: 'GridPanel',
910                         xns: Roo,
911                         listeners : {
912                             activate : function() {
913                                 _this.detailpanel = this;
914                                 if (_this.detailgrid) {
915                                     _this.detailgrid.footer.onClick('first');
916                                 }
917                             }
918                         },
919                         background : true,
920                         fitContainer : true,
921                         fitToframe : true,
922                         region : 'east',
923                         tableName : 'Events',
924                         title : "Detail",
925                         grid : {
926                             xtype: 'Grid',
927                             xns: Roo.grid,
928                             listeners : {
929                                 render : function() 
930                                 {
931                                     _this.detailgrid = this; 
932                                     //_this.dialog = Pman.Dialog.FILL_IN
933                                     if (_this.detailpanel.active) {
934                                        this.footer.onClick('first');
935                                     }
936                                 }
937                             },
938                             autoExpandColumn : 'person_name',
939                             loadMask : true,
940                             dataSource : {
941                                 xtype: 'Store',
942                                 xns: Roo.data,
943                                 listeners : {
944                                     beforeload : function (_self, o)
945                                     {
946                                          if (! _this.dategrid) {
947                                              return false;
948                                         }
949                                         
950                                         o.params = o.params || {};
951                                         
952                                         var s = _this.dategrid.selModel.getSelected();
953                                         if (!s) {
954                                             _this.detailgrid.view.el.mask("Select a person");
955                                             return false;
956                                         }
957                                         
958                                         o.params.person_id = s.data.person_id;    
959                                         
960                                         var s = _this.tablegrid.selModel.getSelected();
961                                         if (!s) {
962                                             _this.detailgrid.view.el.mask("Select a table");
963                                             return false;
964                                         }
965                                         o.params.on_table = s.data.on_table;        
966                                         
967                                         _this.detailgrid.view.el.unmask();
968                                      
969                                         var act = _this.actionSel.getValue();
970                                         if (act.length) {
971                                             o.params.action = act;
972                                         }
973                                         var tbl = _this.affectSel.getValue();
974                                         if (tbl.length) {
975                                             o.params.on_table = tbl;
976                                         }
977                                          
978                                      
979                                         act = _this.dateFrom.getValue();
980                                         if (act.format) {
981                                             o.params['query[from]'] = act.format('Y-m-d');
982                                         }
983                                         act = _this.dateTo.getValue();
984                                         if (act.format) {
985                                             o.params['query[to]'] = act.format('Y-m-d');
986                                         }
987                                     
988                                         //o.params['query[table_d]'] = 1;
989                                         //o.params._columns = 'on_table,qty,uqty';
990                                     
991                                         
992                                     }
993                                 },
994                                 remoteSort : true,
995                                 sortInfo : { field : 'event_when', direction: 'DESC' },
996                                 proxy : {
997                                     xtype: 'HttpProxy',
998                                     xns: Roo.data,
999                                     method : 'GET',
1000                                     url : baseURL + '/Roo/Events.php'
1001                                 },
1002                                 reader : {
1003                                     xtype: 'JsonReader',
1004                                     xns: Roo.data,
1005                                     totalProperty : 'total',
1006                                     root : 'data',
1007                                     id : 'id',
1008                                     fields : [
1009                                         {
1010                                             'name': 'id',
1011                                             'type': 'int'
1012                                         },
1013                                         {
1014                                             'name': 'person_name',
1015                                             'type': 'string'
1016                                         },
1017                                         {
1018                                             'name': 'event_when',
1019                                             'type': 'date',
1020                                             'dateFormat': 'Y-m-d'
1021                                         },
1022                                         {
1023                                             'name': 'action',
1024                                             'type': 'string'
1025                                         },
1026                                         {
1027                                             'name': 'ipaddr',
1028                                             'type': 'string'
1029                                         },
1030                                         {
1031                                             'name': 'on_id',
1032                                             'type': 'int'
1033                                         },
1034                                         {
1035                                             'name': 'on_table',
1036                                             'type': 'string'
1037                                         },
1038                                         {
1039                                             'name': 'person_id',
1040                                             'type': 'int'
1041                                         },
1042                                         {
1043                                             'name': 'remarks',
1044                                             'type': 'string'
1045                                         },
1046                                         {
1047                                             'name': 'person_id_id',
1048                                             'type': 'int'
1049                                         },
1050                                         {
1051                                             'name': 'person_id_office_id',
1052                                             'type': 'int'
1053                                         },
1054                                         {
1055                                             'name': 'person_id_name',
1056                                             'type': 'string'
1057                                         },
1058                                         {
1059                                             'name': 'person_id_phone',
1060                                             'type': 'string'
1061                                         },
1062                                         {
1063                                             'name': 'person_id_fax',
1064                                             'type': 'string'
1065                                         },
1066                                         {
1067                                             'name': 'person_id_email',
1068                                             'type': 'string'
1069                                         },
1070                                         {
1071                                             'name': 'person_id_company_id',
1072                                             'type': 'int'
1073                                         },
1074                                         {
1075                                             'name': 'person_id_role',
1076                                             'type': 'string'
1077                                         },
1078                                         {
1079                                             'name': 'person_id_active',
1080                                             'type': 'int'
1081                                         },
1082                                         {
1083                                             'name': 'person_id_remarks',
1084                                             'type': 'string'
1085                                         },
1086                                         {
1087                                             'name': 'person_id_passwd',
1088                                             'type': 'string'
1089                                         },
1090                                         {
1091                                             'name': 'person_id_owner_id',
1092                                             'type': 'int'
1093                                         },
1094                                         {
1095                                             'name': 'person_id_lang',
1096                                             'type': 'string'
1097                                         },
1098                                         {
1099                                             'name': 'person_id_no_reset_sent',
1100                                             'type': 'int'
1101                                         },
1102                                         {
1103                                             'name': 'person_id_action_type',
1104                                             'type': 'string'
1105                                         },
1106                                         {
1107                                             'name': 'person_id_project_id',
1108                                             'type': 'int'
1109                                         },
1110                                         {
1111                                             'name': 'person_id_deleted_by',
1112                                             'type': 'int'
1113                                         },
1114                                         {
1115                                             'name': 'person_id_deleted_dt',
1116                                             'type': 'date'
1117                                         }
1118                                     ]
1119                                 }
1120                             },
1121                             footer : {
1122                                 xtype: 'PagingToolbar',
1123                                 xns: Roo,
1124                                 pageSize : 25,
1125                                 displayInfo : true,
1126                                 displayMsg : "Displaying Events{0} - {1} of {2}",
1127                                 emptyMsg : "No Events found"
1128                             },
1129                             colModel : [
1130                                 {
1131                                     xtype: 'ColumnModel',
1132                                     xns: Roo.grid,
1133                                     dataIndex : 'id',
1134                                     header : 'Id',
1135                                     width : 50,
1136                                     renderer : function(v) { return String.format('{0}', v); }
1137                                 },
1138                                 {
1139                                     xtype: 'ColumnModel',
1140                                     xns: Roo.grid,
1141                                     header : 'Event when',
1142                                     width : 75,
1143                                     dataIndex : 'event_when',
1144                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
1145                                 },
1146                                 {
1147                                     xtype: 'ColumnModel',
1148                                     xns: Roo.grid,
1149                                     dataIndex : 'action',
1150                                     header : 'Action',
1151                                     width : 50,
1152                                     renderer : function(v) { return String.format('{0}', v); }
1153                                 },
1154                                 {
1155                                     xtype: 'ColumnModel',
1156                                     xns: Roo.grid,
1157                                     dataIndex : 'ipaddr',
1158                                     header : 'Ipaddr',
1159                                     width : 100,
1160                                     renderer : function(v) { return String.format('{0}', v); }
1161                                 },
1162                                 {
1163                                     xtype: 'ColumnModel',
1164                                     xns: Roo.grid,
1165                                     dataIndex : 'on_id',
1166                                     header : '#ID',
1167                                     width : 75,
1168                                     renderer : function(v) { return String.format('{0}', v); }
1169                                 },
1170                                 {
1171                                     xtype: 'ColumnModel',
1172                                     xns: Roo.grid,
1173                                     header : 'Remarks',
1174                                     width : 200,
1175                                     dataIndex : 'remarks',
1176                                     renderer : function(v) { return String.format('{0}', v); }
1177                                 }
1178                             ]
1179                         }
1180                     },
1181                     {
1182                         xtype: 'GridPanel',
1183                         xns: Roo,
1184                         listeners : {
1185                             activate : function() {
1186                                 _this.daypanel = this;
1187                                 if (_this.daygrid) {
1188                                     _this.daygrid.footer.onClick('first');
1189                                 }
1190                             }
1191                         },
1192                         background : true,
1193                         fitContainer : true,
1194                         fitToframe : true,
1195                         region : 'east',
1196                         tableName : 'Events',
1197                         title : "Daily summary",
1198                         grid : {
1199                             xtype: 'Grid',
1200                             xns: Roo.grid,
1201                             listeners : {
1202                                 render : function() 
1203                                 {
1204                                     _this.daygrid = this; 
1205                                     //_this.dialog = Pman.Dialog.FILL_IN
1206                                     if (_this.daypanel.active) {
1207                                        this.footer.onClick('first');
1208                                     }
1209                                 }
1210                             },
1211                             autoExpandColumn : 'person_name',
1212                             loadMask : true,
1213                             dataSource : {
1214                                 xtype: 'Store',
1215                                 xns: Roo.data,
1216                                 listeners : {
1217                                     beforeload : function (_self, o)
1218                                     {
1219                                          if (! _this.dategrid) {
1220                                              return false;
1221                                         }
1222                                         
1223                                         o.params = o.params || {};
1224                                         
1225                                         var s = _this.dategrid.selModel.getSelected();
1226                                         if (!s) {
1227                                             _this.detailgrid.view.el.mask("Select a person");
1228                                             return false;
1229                                         }
1230                                         
1231                                         o.params.person_id = s.data.person_id;    
1232                                         
1233                                         var s = _this.tablegrid.selModel.getSelected();
1234                                         if (!s) {
1235                                             _this.detailgrid.view.el.mask("Select a table");
1236                                             return false;
1237                                         }
1238                                         o.params.on_table = s.data.on_table;        
1239                                         
1240                                         _this.detailgrid.view.el.unmask();
1241                                      
1242                                         var act = _this.actionSel.getValue();
1243                                         if (act.length) {
1244                                             o.params.action = act;
1245                                         }
1246                                         var tbl = _this.affectSel.getValue();
1247                                         if (tbl.length) {
1248                                             o.params.on_table = tbl;
1249                                         }
1250                                          
1251                                      
1252                                         act = _this.dateFrom.getValue();
1253                                         if (act.format) {
1254                                             o.params['query[from]'] = act.format('Y-m-d');
1255                                         }
1256                                         act = _this.dateTo.getValue();
1257                                         if (act.format) {
1258                                             o.params['query[to]'] = act.format('Y-m-d');
1259                                         }
1260                                     
1261                                         o.params['query[day_sum]'] = 1;
1262                                         o.params._columns = 'on_day,qty,uqty';
1263                                     
1264                                         
1265                                     }
1266                                 },
1267                                 remoteSort : true,
1268                                 sortInfo : { field : 'on_day', direction: 'ASC' },
1269                                 proxy : {
1270                                     xtype: 'HttpProxy',
1271                                     xns: Roo.data,
1272                                     method : 'GET',
1273                                     url : baseURL + '/Roo/Events.php'
1274                                 },
1275                                 reader : {
1276                                     xtype: 'JsonReader',
1277                                     xns: Roo.data,
1278                                     totalProperty : 'total',
1279                                     root : 'data',
1280                                     id : 'id',
1281                                     fields : [
1282                                         {
1283                                             'name': 'id',
1284                                             'type': 'int'
1285                                         },
1286                                         {
1287                                             'name': 'person_name',
1288                                             'type': 'string'
1289                                         },
1290                                         {
1291                                             'name': 'event_when',
1292                                             'type': 'date',
1293                                             'dateFormat': 'Y-m-d'
1294                                         },
1295                                         {
1296                                             'name': 'action',
1297                                             'type': 'string'
1298                                         },
1299                                         {
1300                                             'name': 'ipaddr',
1301                                             'type': 'string'
1302                                         },
1303                                         {
1304                                             'name': 'on_id',
1305                                             'type': 'int'
1306                                         },
1307                                         {
1308                                             'name': 'on_table',
1309                                             'type': 'string'
1310                                         },
1311                                         {
1312                                             'name': 'person_id',
1313                                             'type': 'int'
1314                                         },
1315                                         {
1316                                             'name': 'remarks',
1317                                             'type': 'string'
1318                                         },
1319                                         {
1320                                             'name': 'person_id_id',
1321                                             'type': 'int'
1322                                         },
1323                                         {
1324                                             'name': 'person_id_office_id',
1325                                             'type': 'int'
1326                                         },
1327                                         {
1328                                             'name': 'person_id_name',
1329                                             'type': 'string'
1330                                         },
1331                                         {
1332                                             'name': 'person_id_phone',
1333                                             'type': 'string'
1334                                         },
1335                                         {
1336                                             'name': 'person_id_fax',
1337                                             'type': 'string'
1338                                         },
1339                                         {
1340                                             'name': 'person_id_email',
1341                                             'type': 'string'
1342                                         },
1343                                         {
1344                                             'name': 'person_id_company_id',
1345                                             'type': 'int'
1346                                         },
1347                                         {
1348                                             'name': 'person_id_role',
1349                                             'type': 'string'
1350                                         },
1351                                         {
1352                                             'name': 'person_id_active',
1353                                             'type': 'int'
1354                                         },
1355                                         {
1356                                             'name': 'person_id_remarks',
1357                                             'type': 'string'
1358                                         },
1359                                         {
1360                                             'name': 'person_id_passwd',
1361                                             'type': 'string'
1362                                         },
1363                                         {
1364                                             'name': 'person_id_owner_id',
1365                                             'type': 'int'
1366                                         },
1367                                         {
1368                                             'name': 'person_id_lang',
1369                                             'type': 'string'
1370                                         },
1371                                         {
1372                                             'name': 'person_id_no_reset_sent',
1373                                             'type': 'int'
1374                                         },
1375                                         {
1376                                             'name': 'person_id_action_type',
1377                                             'type': 'string'
1378                                         },
1379                                         {
1380                                             'name': 'person_id_project_id',
1381                                             'type': 'int'
1382                                         },
1383                                         {
1384                                             'name': 'person_id_deleted_by',
1385                                             'type': 'int'
1386                                         },
1387                                         {
1388                                             'name': 'person_id_deleted_dt',
1389                                             'type': 'date'
1390                                         }
1391                                     ]
1392                                 }
1393                             },
1394                             footer : {
1395                                 xtype: 'PagingToolbar',
1396                                 xns: Roo,
1397                                 pageSize : 25,
1398                                 displayInfo : true,
1399                                 displayMsg : "Displaying Events{0} - {1} of {2}",
1400                                 emptyMsg : "No Events found"
1401                             },
1402                             colModel : [
1403                                 {
1404                                     xtype: 'ColumnModel',
1405                                     xns: Roo.grid,
1406                                     dataIndex : 'on_day',
1407                                     header : 'Event when',
1408                                     sortable : true,
1409                                     width : 75,
1410                                     renderer : function(v) { return String.format('{0}', v  ); }
1411                                 },
1412                                 {
1413                                     xtype: 'ColumnModel',
1414                                     xns: Roo.grid,
1415                                     dataIndex : 'uqty',
1416                                     header : '#Affected',
1417                                     sortable : true,
1418                                     width : 70,
1419                                     renderer : function(v) { return String.format('{0}', v); }
1420                                 },
1421                                 {
1422                                     xtype: 'ColumnModel',
1423                                     xns: Roo.grid,
1424                                     dataIndex : 'qty',
1425                                     header : 'Changes',
1426                                     sortable : true,
1427                                     width : 70,
1428                                     renderer : function(v) { return String.format('{0}', v); }
1429                                 }
1430                             ]
1431                         }
1432                     }
1433                 ],
1434                 west : {
1435                     xtype: 'LayoutRegion',
1436                     xns: Roo,
1437                     split : true,
1438                     width : 270
1439                 },
1440                 center : {
1441                     xtype: 'LayoutRegion',
1442                     xns: Roo
1443                 },
1444                 east : {
1445                     xtype: 'LayoutRegion',
1446                     xns: Roo,
1447                     split : true,
1448                     tabPosition : 'top',
1449                     width : 600
1450                 }
1451             }
1452         });
1453         this.layout = this.panel.layout;
1454
1455     }
1456 });