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