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