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