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 != 'accessmask') {
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: 'Fill',
559                             xns: Roo.Toolbar
560                         }
561                     ]
562                 },
563                 colModel : [
564                     {
565                         xtype: 'ColumnModel',
566                         xns: Roo.grid,
567                         dataIndex : 'accessmask',
568                         header : 'All',
569                         sortable : false,
570                         width : 50,
571                         renderer : function(v,x,r) {
572                             var state = v> 0 ?  '-checked' : '';
573                         
574                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
575                         }
576                     },
577                     {
578                         xtype: 'ColumnModel',
579                         xns: Roo.grid,
580                         dataIndex : 'rightname',
581                         header : 'Module',
582                         sortable : false,
583                         width : 150,
584                         renderer : function(v,x,r) {
585                             if(!v){
586                                 return;
587                             }
588                             return String.format('<span qtip="{1}">{0}</span>', v.split('.').shift(), v);
589                         }
590                     },
591                     {
592                         xtype: 'ColumnModel',
593                         xns: Roo.grid,
594                         dataIndex : 'descript',
595                         header : 'Permission',
596                         sortable : false,
597                         width : 300,
598                         renderer : function(v,x,r)
599                         {
600                             if (r.json.descript && r.json.descript.length) {
601                                 return String.format('{0}',r.json.descript);
602                             }
603                             
604                             return '???' + v;
605                         }
606                     },
607                     {
608                         xtype: 'ColumnModel',
609                         xns: Roo.grid,
610                         dataIndex : 'accessmask_A',
611                         header : 'Add',
612                         width : 75,
613                         renderer : function(v) {  
614                             var state = v> 0 ?  '-checked' : '';
615                         
616                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
617                                         
618                          }
619                     },
620                     {
621                         xtype: 'ColumnModel',
622                         xns: Roo.grid,
623                         dataIndex : 'accessmask_E',
624                         header : 'Edit',
625                         width : 75,
626                         renderer : function(v) {  
627                             var state = v> 0 ?  '-checked' : '';
628                         
629                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
630                                         
631                          }
632                     },
633                     {
634                         xtype: 'ColumnModel',
635                         xns: Roo.grid,
636                         dataIndex : 'accessmask_D',
637                         header : 'Delete',
638                         width : 75,
639                         renderer : function(v) {  
640                             var state = v> 0 ?  '-checked' : '';
641                         
642                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
643                                         
644                          }
645                     },
646                     {
647                         xtype: 'ColumnModel',
648                         xns: Roo.grid,
649                         dataIndex : 'accessmask_S',
650                         header : 'List/View',
651                         width : 75,
652                         renderer : function(v) {  
653                             var state = v> 0 ?  '-checked' : '';
654                         
655                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
656                                         
657                          }
658                     },
659                     {
660                         xtype: 'ColumnModel',
661                         xns: Roo.grid,
662                         dataIndex : 'accessmask_P',
663                         header : 'Print/Export',
664                         width : 75,
665                         renderer : function(v) {  
666                             var state = v> 0 ?  '-checked' : '';
667                         
668                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
669                                         
670                          }
671                     }
672                 ]
673             }
674         };
675     }
676 });