Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
6     part     :  ["Admin","ContactsGroupRight"],
7     order    : '001-Pman.Tab.AdminContactsGroupRight',
8     region   : 'center',
9     parent   : 'Pman.Tab.AdminContactsManager',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             autoScroll : true,
29             background : true,
30             fitContainer : true,
31             fitToframe : true,
32             region : 'center',
33             tableName : 'Person',
34             title : "Rights",
35             grid : {
36                 xtype: 'Grid',
37                 xns: Roo.grid,
38                 listeners : {
39                     render : function() 
40                     {
41                         _this.grid = this; 
42                         if (!_this.dialog) {
43                             _this.dialog = Pman.Dialog.PersonEdit;
44                             
45                         }
46                         //_this.dialog = Pman.Dialog.FILL_IN
47                         if (_this.panel.active) {
48                            this.footer.onClick('first');
49                         }
50                     },
51                     rowdblclick : function (_self, rowIndex, e)
52                     {
53                         if (!_this.dialog) return;
54                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
55                             _this.grid.footer.onClick('first');
56                         }); 
57                     },
58                     cellclick : function (_self, rowIndex, columnIndex, e)
59                     {
60                     
61                             var di = this.colModel.getDataIndex(columnIndex);
62                             if (di != 'active') {
63                                 return;
64                             }
65                              
66                             var rec = _this.grid.ds.getAt(rowIndex);
67                             
68                             rec.set('active', rec.data.active ? 0 : 1);
69                             rec.commit();
70                              
71                             
72                     }
73                 },
74                 ddGroup : 'groupDD',
75                 enableDrag : true,
76                 loadMask : true,
77                 dataSource : {
78                     xtype: 'Store',
79                     xns: Roo.data,
80                     listeners : {
81                         beforeload : function (_self, o)
82                         {
83                             if (!o.params) {
84                                 o.params = {}
85                             }
86                             var s = Pman.Tab.Groups.grid.getSelectionModel().getSelections();
87                             if (!s.length) {
88                                 o.params.group_id = -1;
89                             } else {
90                                 o.params.group_id = s[0].data.id;
91                             }
92                             if (o.params.group_id < 0) {
93                                 _this.grid.getView().el.mask("You can not set permissions for that group");
94                                 return false;
95                             }
96                             _this.grid.getView().el.unmask();
97                             return true;
98                           
99                         },
100                         update : function (_self, record, operation)
101                         {
102                             if (operation != 'commit') {
103                                 return;
104                             }
105                             // only used to change active status.
106                             
107                             new Pman.Request({
108                                 url : baseURL + '/Roo/Person.php',
109                                 method :'POST',
110                                 params : {
111                                     id : record.data.id,
112                                     active: record.data.active
113                                     
114                                 },
115                                 success : function() {
116                                     // do nothing
117                                     
118                                     _this.grid.ds.remove(record);
119                                     
120                                 },
121                                 failure : function() 
122                                 {
123                                     Roo.MessageBox.alert("Error", "saving failed", function() {
124                                         _this.grid.footer.onClick('first');
125                                     });
126                                 }
127                             });
128                         }
129                     },
130                     remoteSort : true,
131                     sortInfo : { field : 'name', direction: 'ASC' },
132                     proxy : {
133                         xtype: 'HttpProxy',
134                         xns: Roo.data,
135                         method : 'GET',
136                         url : baseURL + '/Admin/GroupRights.php'
137                     },
138                     reader : {
139                         xtype: 'JsonReader',
140                         xns: Roo.data,
141                         totalProperty : 'total',
142                         root : 'data',
143                         id : 'id',
144                         fields : [
145                             {
146                                 'name': 'id',
147                                 'type': 'int'
148                             },
149                             {
150                                 'name': 'office_id',
151                                 'type': 'int'
152                             },
153                             {
154                                 'name': 'name',
155                                 'type': 'string'
156                             },
157                             {
158                                 'name': 'phone',
159                                 'type': 'string'
160                             },
161                             {
162                                 'name': 'fax',
163                                 'type': 'string'
164                             },
165                             {
166                                 'name': 'email',
167                                 'type': 'string'
168                             },
169                             {
170                                 'name': 'company_id',
171                                 'type': 'int'
172                             },
173                             {
174                                 'name': 'role',
175                                 'type': 'string'
176                             },
177                             {
178                                 'name': 'active',
179                                 'type': 'int'
180                             },
181                             {
182                                 'name': 'remarks',
183                                 'type': 'string'
184                             },
185                             {
186                                 'name': 'passwd',
187                                 'type': 'string'
188                             },
189                             {
190                                 'name': 'owner_id',
191                                 'type': 'int'
192                             },
193                             {
194                                 'name': 'lang',
195                                 'type': 'string'
196                             },
197                             {
198                                 'name': 'no_reset_sent',
199                                 'type': 'int'
200                             },
201                             {
202                                 'name': 'action_type',
203                                 'type': 'string'
204                             },
205                             {
206                                 'name': 'project_id',
207                                 'type': 'int'
208                             },
209                             {
210                                 'name': 'office_id_id',
211                                 'type': 'int'
212                             },
213                             {
214                                 'name': 'office_id_company_id',
215                                 'type': 'int'
216                             },
217                             {
218                                 'name': 'office_id_name',
219                                 'type': 'string'
220                             },
221                             {
222                                 'name': 'office_id_address',
223                                 'type': 'string'
224                             },
225                             {
226                                 'name': 'office_id_phone',
227                                 'type': 'string'
228                             },
229                             {
230                                 'name': 'office_id_fax',
231                                 'type': 'string'
232                             },
233                             {
234                                 'name': 'office_id_email',
235                                 'type': 'string'
236                             },
237                             {
238                                 'name': 'office_id_role',
239                                 'type': 'string'
240                             },
241                             {
242                                 'name': 'company_id_code',
243                                 'type': 'string'
244                             },
245                             {
246                                 'name': 'company_id_name',
247                                 'type': 'string'
248                             },
249                             {
250                                 'name': 'company_id_remarks',
251                                 'type': 'string'
252                             },
253                             {
254                                 'name': 'company_id_owner_id',
255                                 'type': 'int'
256                             },
257                             {
258                                 'name': 'company_id_address',
259                                 'type': 'string'
260                             },
261                             {
262                                 'name': 'company_id_tel',
263                                 'type': 'string'
264                             },
265                             {
266                                 'name': 'company_id_fax',
267                                 'type': 'string'
268                             },
269                             {
270                                 'name': 'company_id_email',
271                                 'type': 'string'
272                             },
273                             {
274                                 'name': 'company_id_id',
275                                 'type': 'int'
276                             },
277                             {
278                                 'name': 'company_id_isOwner',
279                                 'type': 'int'
280                             },
281                             {
282                                 'name': 'company_id_logo_id',
283                                 'type': 'int'
284                             },
285                             {
286                                 'name': 'company_id_background_color',
287                                 'type': 'string'
288                             },
289                             {
290                                 'name': 'company_id_comptype',
291                                 'type': 'string'
292                             },
293                             {
294                                 'name': 'company_id_url',
295                                 'type': 'string'
296                             },
297                             {
298                                 'name': 'company_id_main_office_id',
299                                 'type': 'int'
300                             },
301                             {
302                                 'name': 'company_id_created_by',
303                                 'type': 'int'
304                             },
305                             {
306                                 'name': 'company_id_created_dt',
307                                 'type': 'date'
308                             },
309                             {
310                                 'name': 'company_id_updated_by',
311                                 'type': 'int'
312                             },
313                             {
314                                 'name': 'company_id_updated_dt',
315                                 'type': 'date'
316                             },
317                             {
318                                 'name': 'company_id_passwd',
319                                 'type': 'string'
320                             },
321                             {
322                                 'name': 'project_id_id',
323                                 'type': 'int'
324                             },
325                             {
326                                 'name': 'project_id_name',
327                                 'type': 'string'
328                             },
329                             {
330                                 'name': 'project_id_remarks',
331                                 'type': 'string'
332                             },
333                             {
334                                 'name': 'project_id_owner_id',
335                                 'type': 'int'
336                             },
337                             {
338                                 'name': 'project_id_code',
339                                 'type': 'string'
340                             },
341                             {
342                                 'name': 'project_id_active',
343                                 'type': 'int'
344                             },
345                             {
346                                 'name': 'project_id_type',
347                                 'type': 'string'
348                             },
349                             {
350                                 'name': 'project_id_client_id',
351                                 'type': 'int'
352                             },
353                             {
354                                 'name': 'project_id_team_id',
355                                 'type': 'int'
356                             },
357                             {
358                                 'name': 'project_id_file_location',
359                                 'type': 'string'
360                             },
361                             {
362                                 'name': 'project_id_open_date',
363                                 'type': 'date'
364                             },
365                             {
366                                 'name': 'project_id_open_by',
367                                 'type': 'int'
368                             },
369                             {
370                                 'name': 'project_id_close_date',
371                                 'type': 'date'
372                             },
373                             {
374                                 'name': 'project_id_countries',
375                                 'type': 'string'
376                             },
377                             {
378                                 'name': 'project_id_languages',
379                                 'type': 'string'
380                             },
381                             {
382                                 'name': 'project_id_agency_id',
383                                 'type': 'int'
384                             },
385                             {
386                                 'name': 'owner_id_id',
387                                 'type': 'int'
388                             },
389                             {
390                                 'name': 'owner_id_office_id',
391                                 'type': 'int'
392                             },
393                             {
394                                 'name': 'owner_id_name',
395                                 'type': 'string'
396                             },
397                             {
398                                 'name': 'owner_id_phone',
399                                 'type': 'string'
400                             },
401                             {
402                                 'name': 'owner_id_fax',
403                                 'type': 'string'
404                             },
405                             {
406                                 'name': 'owner_id_email',
407                                 'type': 'string'
408                             },
409                             {
410                                 'name': 'owner_id_company_id',
411                                 'type': 'int'
412                             },
413                             {
414                                 'name': 'owner_id_role',
415                                 'type': 'string'
416                             },
417                             {
418                                 'name': 'owner_id_active',
419                                 'type': 'int'
420                             },
421                             {
422                                 'name': 'owner_id_remarks',
423                                 'type': 'string'
424                             },
425                             {
426                                 'name': 'owner_id_passwd',
427                                 'type': 'string'
428                             },
429                             {
430                                 'name': 'owner_id_owner_id',
431                                 'type': 'int'
432                             },
433                             {
434                                 'name': 'owner_id_lang',
435                                 'type': 'string'
436                             },
437                             {
438                                 'name': 'owner_id_no_reset_sent',
439                                 'type': 'int'
440                             },
441                             {
442                                 'name': 'owner_id_action_type',
443                                 'type': 'string'
444                             },
445                             {
446                                 'name': 'owner_id_project_id',
447                                 'type': 'int'
448                             }
449                         ]
450                     }
451                 },
452                 footer : {
453                     xtype: 'PagingToolbar',
454                     xns: Roo,
455                     pageSize : 25,
456                     displayInfo : true,
457                     displayMsg : "Displaying Person{0} - {1} of {2}",
458                     emptyMsg : "No Person found",
459                     items : [
460                         {
461                             xtype: 'TextItem',
462                             xns: Roo.Toolbar,
463                             text : "Drag person to add or remove from group"
464                         }
465                     ]
466                 },
467                 toolbar : {
468                     xtype: 'Toolbar',
469                     xns: Roo,
470                     items : [
471                         {
472                             xtype: 'TextItem',
473                             xns: Roo.Toolbar,
474                             text : "Search"
475                         },
476                         {
477                             xtype: 'TextField',
478                             xns: Roo.form,
479                             listeners : {
480                                 render : function (_self)
481                                 {
482                                     _this.searchBox = _self;
483                                 },
484                                 show : function (_self,e)
485                                 {
486                                     if (e.getCharCode() != 13) {
487                                         return;
488                                     }
489                                     _this.grid.footer.onClick('first');
490                                 },
491                                 specialkey : function (_self, e)
492                                 {
493                                   if (e.getKey() == 13) {
494                                     _this.grid.footer.onClick('first');
495                                   }
496                                 }
497                             }
498                         },
499                         {
500                             xtype: 'ComboBox',
501                             xns: Roo.form,
502                             listeners : {
503                                 render : function (_self)
504                                 {
505                                   _this.companyCombo = _self;
506                                 },
507                                 select : function (combo, record, index)
508                                 {
509                                    _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );
510                                 }
511                             },
512                             displayField : 'name',
513                             editable : true,
514                             emptyText : "Select Company",
515                             forceSelection : true,
516                             hiddenName : 'company_id',
517                             listWidth : 400,
518                             loadingText : "Searching...",
519                             minChars : 2,
520                             name : 'company_name',
521                             pageSize : 20,
522                             qtip : "Select Companies",
523                             queryParam : 'query[name]',
524                             selectOnFocus : true,
525                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
526                             triggerAction : 'all',
527                             typeAhead : true,
528                             valueField : 'id',
529                             width : 150,
530                             store : {
531                                 xtype: 'Store',
532                                 xns: Roo.data,
533                                 listeners : {
534                                     beforeload : function (_self, o){
535                                         o.params = o.params || {};
536                                         // set more here
537                                     }
538                                 },
539                                 remoteSort : true,
540                                 sortInfo : { direction : 'ASC', field: 'name' },
541                                 proxy : {
542                                     xtype: 'HttpProxy',
543                                     xns: Roo.data,
544                                     method : 'GET',
545                                     url : baseURL + '/Roo/Companies.php'
546                                 },
547                                 reader : {
548                                     xtype: 'JsonReader',
549                                     xns: Roo.data,
550                                     id : 'id',
551                                     root : 'data',
552                                     totalProperty : 'total',
553                                     fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
554                                 }
555                             }
556                         },
557                         {
558                             xtype: 'Button',
559                             xns: Roo.Toolbar,
560                             listeners : {
561                                 click : function (_self, e)
562                                 {
563                                 _this.grid.footer.onClick('first');
564                                 }
565                             },
566                             cls : 'x-btn-icon',
567                             icon : rootURL + '/Pman/templates/images/search.gif'
568                         },
569                         {
570                             xtype: 'Button',
571                             xns: Roo.Toolbar,
572                             listeners : {
573                                 click : function (_self, e)
574                                 {
575                                 _this.searchBox.setValue('');
576                                     _this.grid.footer.onClick('first');
577                                 }
578                             },
579                             cls : 'x-btn-icon',
580                             icon : rootURL + '/Pman/templates/images/edit-clear.gif'
581                         },
582                         {
583                             xtype: 'Button',
584                             xns: Roo.Toolbar,
585                             listeners : {
586                                 toggle : function (_self, pressed)
587                                 {
588                                    _this.grid.footer.onClick('first');
589                                    this.setText(pressed ? "Show Active" : "Show Removed");
590                                    
591                                    
592                                 },
593                                 render : function (_self)
594                                 {
595                                   _this.activeButton = _self;
596                                 }
597                             },
598                             enableToggle : true,
599                             text : "Show Removed"
600                         },
601                         {
602                             xtype: 'Button',
603                             xns: Roo.Toolbar,
604                             listeners : {
605                                 toggle : function (_self, pressed)
606                                 {
607                                    _this.grid.footer.onClick('first');
608                                    this.setText(pressed ? "Show Company" : "Show No Company");
609                                    
610                                    
611                                 },
612                                 render : function (_self)
613                                 {
614                                   _this.active_company_button = _self;
615                                 }
616                             },
617                             enableToggle : true,
618                             text : "Show No Company"
619                         },
620                         {
621                             xtype: 'Fill',
622                             xns: Roo.Toolbar
623                         },
624                         {
625                             xtype: 'Button',
626                             xns: Roo.Toolbar,
627                             listeners : {
628                                 click : function()
629                                 {
630                                     var s = _this.grid.getSelectionModel().getSelections();
631                                     if (!s.length || (s.length > 1))  {
632                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
633                                         return;
634                                     }
635                                   
636                                     _this.dialog.show(s[0].data, function() {
637                                         _this.grid.footer.onClick('first');
638                                     }); 
639                                     
640                                 }
641                             },
642                             cls : 'x-btn-text-icon',
643                             text : "Edit",
644                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
645                         },
646                         {
647                             xtype: 'Button',
648                             xns: Roo.Toolbar,
649                             listeners : {
650                                 click : function()
651                                 {
652                                      Pman.genericDelete(_this, 'Person'); 
653                                 }
654                             },
655                             cls : 'x-btn-text-icon',
656                             text : "Delete",
657                             icon : rootURL + '/Pman/templates/images/trash.gif'
658                         }
659                     ]
660                 },
661                 colModel : [
662                     {
663                         xtype: 'ColumnModel',
664                         xns: Roo.grid,
665                         dataIndex : 'accessmask',
666                         header : 'All',
667                         sortable : false,
668                         width : 50,
669                         renderer : function(v,x,r) {
670                             var state = v> 0 ?  '-checked' : '';
671                         
672                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
673                         }
674                     },
675                     {
676                         xtype: 'ColumnModel',
677                         xns: Roo.grid,
678                         dataIndex : 'rightname',
679                         header : 'Module',
680                         sortable : false,
681                         width : 150,
682                         renderer : function(v,x,r) {
683                             if(!v){
684                                 return;
685                             }
686                             return String.format('<span qtip="{1}">{0}</span>', v.split('.').shift(), v);
687                         }
688                     },
689                     {
690                         xtype: 'ColumnModel',
691                         xns: Roo.grid,
692                         dataIndex : 'descript',
693                         header : 'Permission',
694                         sortable : false,
695                         width : 300,
696                         renderer : function(v,x,r)
697                         {
698                             if (r.json.descript && r.json.descript.length) {
699                                 return String.format('{0}',r.json.descript);
700                             }
701                             
702                             return '???' + v;
703                         }
704                     },
705                     {
706                         xtype: 'ColumnModel',
707                         xns: Roo.grid,
708                         dataIndex : 'accessmask_A',
709                         header : 'Add',
710                         width : 75,
711                         renderer : function(v) {  
712                             var state = v> 0 ?  '-checked' : '';
713                         
714                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
715                                         
716                          }
717                     },
718                     {
719                         xtype: 'ColumnModel',
720                         xns: Roo.grid,
721                         dataIndex : 'accessmask_E',
722                         header : 'Edit',
723                         width : 75,
724                         renderer : function(v) {  
725                             var state = v> 0 ?  '-checked' : '';
726                         
727                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
728                                         
729                          }
730                     },
731                     {
732                         xtype: 'ColumnModel',
733                         xns: Roo.grid,
734                         dataIndex : 'accessmask_D',
735                         header : 'Delete',
736                         width : 75,
737                         renderer : function(v) {  
738                             var state = v> 0 ?  '-checked' : '';
739                         
740                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
741                                         
742                          }
743                     },
744                     {
745                         xtype: 'ColumnModel',
746                         xns: Roo.grid,
747                         dataIndex : 'accessmask_S',
748                         header : 'List/View',
749                         width : 75,
750                         renderer : function(v) {  
751                             var state = v> 0 ?  '-checked' : '';
752                         
753                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
754                                         
755                          }
756                     },
757                     {
758                         xtype: 'ColumnModel',
759                         xns: Roo.grid,
760                         dataIndex : 'accessmask_P',
761                         header : 'Print/Export',
762                         width : 75,
763                         renderer : function(v) {  
764                             var state = v> 0 ?  '-checked' : '';
765                         
766                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
767                                         
768                          }
769                     }
770                 ]
771             }
772         };
773     }
774 });