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