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