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