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