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