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