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