sync
[Pman.BAdmin] / Pman.Tab.BAdminStaff.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.BAdminStaff = new Roo.XComponent({
8
9  _strings : {
10   'b15aafc19dc2ba4b788adf77268d8ca4' :"Hide Inactive",
11   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
12   'f29c99f082755399839b64ebaf9f608a' :"List / View",
13   '4f3cdff2e6a5e08440be182ef40d93f7' :"Print / Export",
14   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
15   'a37ede293936e29279ed543129451ec3' :"Groups",
16   '7dce122004969d56ae2e0245cb754d35' :"Edit",
17   '05b763f7d24f32575493b3c23f299b0e' :"Add To Group",
18   'e0a7cc944485bdedafb92b0cf98632fa' :"Remove From Group",
19   'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
20   '25f57527ae8a27c94fb5230b5486c743' :"Permission List",
21   '09f0c5159c5e34504e453eff3fc70324' :"Account Management",
22   '054176c3a541fb2d4b63e29360c749aa' :"Members List",
23   '8a25a3ae30ab6e8ceb5b8c4009a3336f' :"Role / Position",
24   '17050e1914aff1e423a84e76db8ab0d1' :"[All]",
25   '5bc3fd20294c17c9803942958fd7f26d' :"Show Inactive",
26   '4d1c8263ba1036754f8db14a98f9f006' :"Reload",
27   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
28   'ec3249f16ee5880d4c1acb752e5c925f' :"Switch to Selected User",
29   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
30   '49ee3087348e8d44e1feda1917443987' :"Name",
31   'e55f75a29310d7b60f7ac1d390c8ae42' :"Module",
32   'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
33   'aba9f7d7443652e858969bfc280690b1' :"Manage Groups"
34  },
35  _named_strings : {
36   'activeButton_offtext' : '5bc3fd20294c17c9803942958fd7f26d' /* Show Inactive */ ,
37   'activeButton_ontext' : 'b15aafc19dc2ba4b788adf77268d8ca4' /* Hide Inactive */ ,
38   'activeButton_html' : '5bc3fd20294c17c9803942958fd7f26d' /* Show Inactive */ 
39  },
40
41   part     :  ["BAdmin", "Staff" ],
42   order    : '003-Pman.Tab.BAdminStaff',
43   region   : 'center',
44   parent   : 'Pman.Tab.BAdmin',
45   name     : "unnamed module",
46   disabled : false, 
47   permname : '', 
48   _tree : function(_data)
49   {
50    var _this = this;
51    var MODULE = this;
52    return {
53    xtype : 'Nest',
54    background : true,
55    title : _this._strings['09f0c5159c5e34504e453eff3fc70324'] /* Account Management */,
56    listeners : {
57     activate : function (_self)
58      {
59          if ( _this.group_grid) {
60               _this.group_grid.store.load({});
61          }
62      }
63    },
64    xns : Roo.bootstrap.panel,
65    '|xns' : 'Roo.bootstrap.panel',
66    layout : {
67     xtype : 'Border',
68     xns : Roo.bootstrap.layout,
69     '|xns' : 'Roo.bootstrap.layout',
70     center : {
71      xtype : 'Region',
72      tabPosition : 'top',
73      xns : Roo.bootstrap.layout,
74      '|xns' : 'Roo.bootstrap.layout'
75     },
76     west : {
77      xtype : 'Region',
78      split : true,
79      tabPosition : 'top',
80      width : 250,
81      xns : Roo.bootstrap.layout,
82      '|xns' : 'Roo.bootstrap.layout'
83     },
84     items  : [
85      {
86       xtype : 'Grid',
87       background : false,
88       closable : false,
89       fitContainer : true,
90       fitToFrame : true,
91       region : 'center',
92       title : _this._strings['054176c3a541fb2d4b63e29360c749aa'] /* Members List */,
93       listeners : {
94        activate : function (_self)
95         {
96             _this.edit_btn.el.hide();
97             _this.delete_btn.el.hide();
98             _this.addToGroupBtn.el.hide();
99             _this.removeFromGroupBtn.el.hide();
100             _this.switch_btn.el.hide();
101         
102             if(_this.member_grid) {
103                 _this.member_grid.footer.onClick('first');
104             }
105         },
106        render : function (_self)
107         {
108             _this.member_panel = _self; 
109         }
110       },
111       xns : Roo.bootstrap.panel,
112       '|xns' : 'Roo.bootstrap.panel',
113       toolbar : {
114        xtype : 'NavSimplebar',
115        xns : Roo.bootstrap,
116        '|xns' : 'Roo.bootstrap',
117        items  : [
118         {
119          xtype : 'NavGroup',
120          style : 'width: 100%;',
121          xns : Roo.bootstrap,
122          '|xns' : 'Roo.bootstrap',
123          items  : [
124           {
125            xtype : 'NavItem',
126            style : 'width: 100%;',
127            xns : Roo.bootstrap,
128            '|xns' : 'Roo.bootstrap',
129            items  : [
130             {
131              xtype : 'Element',
132              style : 'width: 100%;',
133              xns : Roo.bootstrap,
134              '|xns' : 'Roo.bootstrap',
135              items  : [
136               {
137                xtype : 'Row',
138                cls : 'roo-toolbar',
139                xns : Roo.bootstrap,
140                '|xns' : 'Roo.bootstrap',
141                items  : [
142                 {
143                  xtype : 'Column',
144                  md : 9,
145                  xns : Roo.bootstrap,
146                  '|xns' : 'Roo.bootstrap',
147                  items  : [
148                   {
149                    xtype : 'Button',
150                    cls : 'roo-toolbar-button',
151                    glyphicon : 'plus',
152                    html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
153                    weight : 'default',
154                    listeners : {
155                     click : function (_self, e)
156                      {
157                          Pman.Dialog.BAdminStaff.show({ 
158                              id : 0,
159                              company_id : Pman.Login.authUser.company_id
160                          }, function(res) {
161                          
162                              if(res.length_oath_key * 1 < 1){
163                                  _this.member_grid.footer.onClick('first');
164                                  return;
165                              }
166                              
167                              Pman.Dialog.BAdminStaffTwoFactorQRCode.show({
168                                  id : res.id,
169                                  allow_close: false,
170                                  allow_cancel : true
171                              }, function(res){
172                                  _this.member_grid.footer.onClick('first');
173                              });
174                          }); 
175                      
176                      }
177                    },
178                    xns : Roo.bootstrap,
179                    '|xns' : 'Roo.bootstrap'
180                   },
181                   {
182                    xtype : 'Button',
183                    cls : 'roo-toolbar-button',
184                    glyphicon : 'edit',
185                    html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
186                    weight : 'default',
187                    listeners : {
188                     click : function (_self, e)
189                      {
190                          var sel = _this.member_grid.getSelectionModel().getSelections();
191                          
192                          if(!sel.length){
193                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');
194                              return;
195                          }
196                          
197                          if(sel.length > 1){
198                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a single person');
199                              return;
200                          }
201                          
202                          var s = _this.member_grid.getSelectionModel().getSelected();
203                          
204                          if(s.data.id * 1 < 1){
205                              Roo.bootstrap.MessageBox.alert('Error', 'Invalid person');
206                              return;
207                          }
208                          
209                          Pman.Dialog.BAdminStaff.show( { id : s.data.id }, function() {
210                              _this.member_grid.footer.onClick('first');
211                          });
212                          
213                      },
214                     render : function (_self)
215                      {
216                          _this.edit_btn = this;
217                          
218                          this.el.setVisibilityMode(Roo.Element.DISPLAY);
219                          
220                          this.el.hide();
221                      }
222                    },
223                    xns : Roo.bootstrap,
224                    '|xns' : 'Roo.bootstrap'
225                   },
226                   {
227                    xtype : 'Button',
228                    cls : 'roo-toolbar-button',
229                    glyphicon : 'trash',
230                    html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
231                    weight : 'primary',
232                    listeners : {
233                     click : function (_self, e)
234                      {
235                          // from pman.js
236                          Pman.genericDelete(_this.member_panel, 'core_person');
237                          
238                          
239                      },
240                     render : function (_self)
241                      {
242                          _this.delete_btn = this;
243                          
244                          this.el.setVisibilityMode(Roo.Element.DISPLAY);
245                          
246                          this.el.hide();
247                      }
248                    },
249                    xns : Roo.bootstrap,
250                    '|xns' : 'Roo.bootstrap'
251                   },
252                   {
253                    xtype : 'Button',
254                    cls : 'roo-toolbar-button',
255                    glyphicon : 'plus',
256                    html : _this._strings['05b763f7d24f32575493b3c23f299b0e'] /* Add To Group */,
257                    weight : 'default',
258                    listeners : {
259                     click : function (_self, e)
260                      {
261                          var sel = _this.member_grid.getSelectionModel().getSelections();
262                          
263                          if(!sel.length){
264                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');
265                              return;
266                          }
267                          
268                          var ids = [];
269                          
270                          Roo.each(sel, function(r){
271                              if(r.data.id * 1 < 1){
272                                  return;
273                              }
274                              
275                              ids.push(r.data.id);
276                          });
277                          
278                          if(!ids.length){
279                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');
280                              return;
281                          }
282                          
283                          Pman.Dialog.BAdminAddToGroup.show({
284                              user_ids : ids.join(',')
285                              
286                          }, function(res){
287                              _this.member_grid.footer.onClick('first');
288                          });
289                          
290                      },
291                     render : function (_self)
292                      {
293                          _this.addToGroupBtn = this;
294                          
295                          this.el.setVisibilityMode(Roo.Element.DISPLAY);
296                          
297                          this.el.hide();
298                      }
299                    },
300                    xns : Roo.bootstrap,
301                    '|xns' : 'Roo.bootstrap'
302                   },
303                   {
304                    xtype : 'Button',
305                    cls : 'roo-toolbar-button',
306                    glyphicon : 'trash',
307                    html : _this._strings['e0a7cc944485bdedafb92b0cf98632fa'] /* Remove From Group */,
308                    weight : 'default',
309                    listeners : {
310                     click : function (_self, e)
311                      {
312                          var sel = _this.member_grid.getSelectionModel().getSelections();
313                          
314                          if(!sel.length){
315                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');
316                              return;
317                          }
318                          
319                          var ids = [];
320                          
321                          Roo.each(sel, function(r){
322                              if(r.data.id * 1 < 1){
323                                  return;
324                              }
325                              
326                              ids.push(r.data.id);
327                          });
328                          
329                          if(!ids.length){
330                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');
331                              return;
332                          }
333                          
334                          var group = _this.group_grid.getSelectionModel().getSelected();
335                          
336                          if(!group || group.data.id < 1){
337                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
338                              return;
339                          }
340                          
341                          new Pman.Request({
342                              url: baseURL + '/Roo/Core_group',
343                              method: 'POST',
344                              params: {
345                                  group_id : group.data.id,
346                                  _action : 'sub',
347                                  user_ids : ids.join(',')
348                              },
349                              success: function(res){
350                                  _this.member_grid.footer.onClick('first');
351                                  return;
352                              }
353                          });
354                          
355                          
356                      },
357                     render : function (_self)
358                      {
359                          _this.removeFromGroupBtn = this;
360                          
361                          this.el.setVisibilityMode(Roo.Element.DISPLAY);
362                          
363                          this.el.hide();
364                      }
365                    },
366                    xns : Roo.bootstrap,
367                    '|xns' : 'Roo.bootstrap'
368                   },
369                   {
370                    xtype : 'Button',
371                    cls : 'roo-toolbar-button',
372                    glyphicon : 'user',
373                    html : _this._strings['ec3249f16ee5880d4c1acb752e5c925f'] /* Switch to Selected User */,
374                    weight : 'default',
375                    listeners : {
376                     click : function (_self, e)
377                      {
378                          var s = _this.member_grid.getSelectionModel().getSelections();
379                          
380                          if (s.length != 1)  {
381                              Roo.MessageBox.alert("Error",  "Select a Person");
382                              return;
383                          }
384                          
385                          new Pman.Request({
386                              url : baseURL+ '/Login.php',
387                              params  :{
388                                  'switch' : s[0].data.id
389                              },
390                              method : 'GET',
391                              success : function() {
392                                  document.location = baseURL + '?ts=' + Math.random();
393                                  
394                              }, 
395                              failure : function(d) {
396                                  Roo.log(d);
397                                  Roo.MessageBox.alert("Error",  d);
398                              }
399                          });
400                      },
401                     render : function (_self)
402                      {
403                          _this.switch_btn = this;
404                          
405                          this.el.setVisibilityMode(Roo.Element.DISPLAY);
406                          
407                          this.el.hide();
408                      }
409                    },
410                    xns : Roo.bootstrap,
411                    '|xns' : 'Roo.bootstrap'
412                   }
413                  ]
414                 },
415                 {
416                  xtype : 'Column',
417                  cls : 'text-right',
418                  md : 3,
419                  xns : Roo.bootstrap,
420                  '|xns' : 'Roo.bootstrap',
421                  items  : [
422                   {
423                    xtype : 'Button',
424                    cls : 'roo-toolbar-button',
425                    html : _this._strings['5bc3fd20294c17c9803942958fd7f26d'] /* Show Inactive */,
426                    name : 'activeButton',
427                    _offtext : _this._strings['5bc3fd20294c17c9803942958fd7f26d'] /* Show Inactive */,
428                    _ontext : _this._strings['b15aafc19dc2ba4b788adf77268d8ca4'] /* Hide Inactive */,
429                    pressed : false,
430                    weight : 'default',
431                    listeners : {
432                     render : function (_self)
433                      {
434                          _this.footerActiveBtn = this;
435                      },
436                     toggle : function (_self, e, pressed)
437                      {
438                          this.setText(this.pressed ? this._ontext : this._offtext);
439                      
440                          _this.member_grid.footer.onClick('first');
441                          
442                          return;
443                          
444                      }
445                    },
446                    xns : Roo.bootstrap,
447                    '|xns' : 'Roo.bootstrap'
448                   }
449                  ]
450                 }
451                ]
452               }
453              ]
454             }
455            ]
456           }
457          ]
458         }
459        ]
460       },
461       grid : {
462        xtype : 'Table',
463        auto_hide_footer : true,
464        cellSelection : true,
465        cls : 'table-fixed',
466        hover : true,
467        loadMask : true,
468        responsive : true,
469        rowSelection : true,
470        striped : false,
471        listeners : {
472         cellclick : function (_self, el, rowIndex, columnIndex, e)
473          {
474              var di = _this.member_grid.colModel.getDataIndex(columnIndex);
475              
476              if (di != 'active') {
477                  return;
478              }
479               
480              var rec = _this.member_grid.store.getAt(rowIndex);
481              
482              rec.set('active', rec.data.active ? 0 : 1);
483              rec.commit();
484          
485              
486              // get the row number to make class x-row-0, x-row-1
487              
488              if(rec.data.active * 1 != 1){
489                  var el = _this.member_grid.getRowDom(rowIndex);
490                  
491                  el.addClass('x-grid-row-fadeout');
492                  
493                  el.on('transitionend',function(){
494                      _this.member_grid.ds.remove(rec);
495                      el.remove();
496                  },this,{single:true});
497              }
498          },
499         render : function (_self)
500          {
501              _this.member_grid = _self;
502             
503          },
504         rowdblclick : function (_self, el, rowIndex, e)
505          {
506              var s = _this.member_grid.store.getAt(rowIndex);
507              
508              if(s.data.id * 1 < 1){
509                  return;
510              }
511              
512              Pman.Dialog.BAdminStaff.show( { id : s.data.id }, function() {
513                  _this.member_grid.footer.onClick('first');
514              });
515          }
516        },
517        xns : Roo.bootstrap,
518        '|xns' : 'Roo.bootstrap',
519        footer : {
520         xtype : 'PagingToolbar',
521         displayInfo : false,
522         name : 'footer',
523         pageSize : 25,
524         xns : Roo.bootstrap,
525         '|xns' : 'Roo.bootstrap'
526        },
527        store : {
528         xtype : 'Store',
529         remoteSort : true,
530         sortInfo : { field: 'name', direction: 'ASC' },
531         listeners : {
532          beforeload : function (_self, options)
533           {
534               if (!Pman.buildCompleted) {
535                   return false;
536               }
537               options.params = options.params || {};
538               
539               //options.params['query[type]'] = 0;
540               //options.params.active = 1;
541               
542               if(!_this.group_grid){
543                   this.removeAll();
544                   return false;
545               }
546               
547               var group = _this.group_grid.getSelectionModel().getSelected();
548               
549               if(!group){
550                   this.removeAll();
551                   return false;
552               }
553               
554               if(_this.footerActiveBtn && !_this.footerActiveBtn.pressed){
555                   options.params.active = 1;
556               }
557               
558               options.params['query[in_group]'] = group.data.id;
559             
560           },
561          load : function (_self, records, options)
562           {
563               _this.edit_btn.el.hide();
564               _this.delete_btn.el.hide();
565               _this.addToGroupBtn.el.hide();
566               _this.removeFromGroupBtn.el.hide();
567               _this.switch_btn.el.hide();
568               
569               options.params.active = 1;
570               
571           
572               
573           },
574          update : function (_self, record, operation)
575           {
576               if (operation != 'commit') {
577                   return;
578               }
579               // only used to change active status.
580                
581               new Pman.Request({
582                   url : baseURL + '/Roo/core_person',
583                   method :'POST',
584                   params : {
585                       id : record.data.id,
586                       active: record.data.active
587                       
588                   },
589                   success : function() {
590                       // do nothing
591                       
592                   },
593                   failure : function() 
594                   {
595                       /*Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
596                           _this.grid.footer.onClick('first');
597                       });*/
598                   }
599               });
600           }
601         },
602         xns : Roo.data,
603         '|xns' : 'Roo.data',
604         proxy : {
605          xtype : 'HttpProxy',
606          method : 'GET',
607          url : baseURL + '/Roo/core_person',
608          xns : Roo.data,
609          '|xns' : 'Roo.data'
610         },
611         reader : {
612          xtype : 'JsonReader',
613          id : 'id',
614          root : 'data',
615          totalProperty : 'total',
616          xns : Roo.data,
617          '|xns' : 'Roo.data'
618         }
619        },
620        sm : {
621         xtype : 'RowSelectionModel',
622         listeners : {
623          selectionchange : function (_self)
624           {
625               _this.edit_btn.el.hide();
626               _this.delete_btn.el.hide();
627               _this.addToGroupBtn.el.hide();
628               _this.removeFromGroupBtn.el.hide();
629               _this.switch_btn.el.hide();
630               
631               if(!_this.member_grid.getSelectionModel().getSelections().length){
632                   return;
633               }
634               
635               _this.edit_btn.el.show();
636               _this.delete_btn.el.show();
637               _this.switch_btn.el.show();
638               
639               var group = _this.group_grid.getSelectionModel().getSelected();
640               
641               if(!group || group.data.id < 1){
642                   _this.addToGroupBtn.el.show();
643                   return;
644               }
645               
646               _this.removeFromGroupBtn.el.show();
647               
648           }
649         },
650         xns : Roo.bootstrap.Table,
651         '|xns' : 'Roo.bootstrap.Table'
652        },
653        cm : [
654         {
655          xtype : 'ColumnModel',
656          align : 'center',
657          cursor : 'pointer',
658          dataIndex : 'active',
659          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
660          md : 1,
661          renderer : function(v) {  
662          
663              var state = v > 0 ?  'check-' : '';
664              var cls = v > 0 ? 'text-primary' : '';
665              
666              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
667                   
668           },
669          sm : 1,
670          sortable : true,
671          xs : 1,
672          xns : Roo.grid,
673          '|xns' : 'Roo.grid'
674         },
675         {
676          xtype : 'ColumnModel',
677          cursor : 'pointer',
678          dataIndex : 'name',
679          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
680          md : 3,
681          renderer : function(v,x,r) {
682              if(r.data.active * 1 != 1){
683                  return "<span class='cell-strikethrough'>"+String.format('{0}', v)+"</span>"; 
684              }
685              return String.format('{0}', v);
686          },
687          sm : 3,
688          sortable : true,
689          xs : 3,
690          xns : Roo.grid,
691          '|xns' : 'Roo.grid'
692         },
693         {
694          xtype : 'ColumnModel',
695          cursor : 'pointer',
696          dataIndex : 'role',
697          header : _this._strings['8a25a3ae30ab6e8ceb5b8c4009a3336f'] /* Role / Position */,
698          md : 2,
699          renderer : function(v) { return String.format('{0}', v); },
700          sm : 2,
701          sortable : true,
702          xs : 2,
703          xns : Roo.grid,
704          '|xns' : 'Roo.grid'
705         },
706         {
707          xtype : 'ColumnModel',
708          cursor : 'pointer',
709          dataIndex : 'phone',
710          header : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
711          md : 2,
712          renderer : function(v) { return String.format('{0}', v); },
713          sm : 2,
714          xs : 2,
715          xns : Roo.grid,
716          '|xns' : 'Roo.grid'
717         },
718         {
719          xtype : 'ColumnModel',
720          cursor : 'pointer',
721          dataIndex : 'email',
722          header : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
723          md : 4,
724          renderer : function (v,x,r) {
725              if(r.data.active * 1 != 1){
726                  return (v.length && v.indexOf('@') > 0 ) ? 
727                      String.format('<a href="mailto:{0}" class="cell-strikethrough">{0}</a>',v) : v;
728              }
729              return (v.length && v.indexOf('@') > 0 ) ? 
730                      String.format('<a href="mailto:{0}">{0}</a>',v) : v;
731                      
732          },
733          sm : 2,
734          sortable : true,
735          xs : 4,
736          xns : Roo.grid,
737          '|xns' : 'Roo.grid'
738         }
739        ]
740       }
741      },
742      {
743       xtype : 'Grid',
744       background : true,
745       closable : false,
746       fitContainer : true,
747       fitToFrame : true,
748       region : 'center',
749       title : _this._strings['25f57527ae8a27c94fb5230b5486c743'] /* Permission List */,
750       listeners : {
751        activate : function (_self)
752         {
753             if(_this.permission_grid) {
754                 _this.permission_grid.store.load({});
755             }
756         },
757        render : function (_self)
758         {
759             _this.permission_panel = this;
760         }
761       },
762       xns : Roo.bootstrap.panel,
763       '|xns' : 'Roo.bootstrap.panel',
764       grid : {
765        xtype : 'Table',
766        cellSelection : true,
767        cls : 'table-fixed',
768        footerShow : false,
769        hover : true,
770        loadMask : true,
771        responsive : true,
772        rowSelection : true,
773        striped : true,
774        listeners : {
775         cellclick : function (_self, el, rowIndex, columnIndex, e)
776          {
777              var di = _this.permission_grid.colModel.getDataIndex(columnIndex);
778              
779              var r = _this.permission_grid.store.getAt(rowIndex);
780              
781              if(di == 'rightname' || di == 'descript' || r.data.id * 1 < 1) {
782                  return;
783              }
784              
785              if(di == 'id'){
786                  
787                  var accessmask = r.data.accessmask.split('').sort().join('');
788                  var fullmask = r.data.FullMask.split('').sort().join('');
789                  
790                  r.set('accessmask', (accessmask == fullmask) ? '' : r.data.FullMask);
791                  
792                  r.commit();
793                  
794                  return;
795              }
796              
797              var mapping = {
798                  'add' : 'A',
799                  'edit' : 'E',
800                  'delete' : 'D',
801                  'view' : 'S',
802                  'print' : 'P'
803              };
804              
805              var target = mapping[di];
806              
807              if(r.data.FullMask.indexOf(target) === -1){
808                  return;
809              }
810              
811              var accessmask = r.data.accessmask.split('');
812              
813              if(accessmask.indexOf(target) !== -1){
814                  accessmask.splice(accessmask.indexOf(target), 1);
815              } else {
816                  accessmask.push(target);
817              }
818              
819              r.set('accessmask', accessmask.sort().join(''));
820              
821              r.commit();
822              
823          },
824         render : function (_self)
825          {
826              _this.permission_grid = this;
827              
828              if(_this.permission_panel.active) {
829                  (function(){
830                      _this.permission_grid.store.load({});
831                  }).defer(50);
832              }
833          }
834        },
835        xns : Roo.bootstrap,
836        '|xns' : 'Roo.bootstrap',
837        store : {
838         xtype : 'Store',
839         remoteSort : true,
840         sortInfo : { field: 'rightname', direction: 'ASC' },
841         listeners : {
842          beforeload : function (_self, o)
843           {
844               if (!Pman.buildCompleted) {
845                   return false;
846               }
847               var group = _this.group_grid.getSelectionModel().getSelected();
848               
849               if(!group){
850                   _this.permission_panel.el.mask('Please select a group');
851                   this.removeAll();
852                   return false;
853               }
854               
855               if(group.data.id * 1 < 1){
856                   _this.permission_panel.el.mask('Please select a group on the left');
857                   this.removeAll();
858                   return false;
859               }
860               
861               _this.permission_panel.el.unmask();
862               
863               o.params = o.params || {};
864                
865               o.params._sort = 1;    
866               o.params.group_id = group.data.id;
867           
868           },
869          update : function (_self, record, operation)
870           {
871               if (operation != 'commit') {
872                   return;
873               }
874           
875               var group = _this.group_grid.getSelectionModel().getSelected();
876               
877               if(!group || group.data.id * 1 < 1){
878                   return;
879               }
880               
881               var params = {};
882               
883               params.group_id = group.data.id;
884               
885               params['dataUpdate[' + record.data.id + ']'] = record.data.accessmask;
886               
887               new Pman.Request({
888                   url : baseURL + '/Admin/GroupRights',
889                   method :'POST',
890                   params : params,
891                   success : function() {
892                       // do nothing
893                   },
894                   failure : function() 
895                   {
896                       Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
897                           _this.permission_grid.store.load({});
898                       });
899                   }
900               });
901               
902           }
903         },
904         xns : Roo.data,
905         '|xns' : 'Roo.data',
906         proxy : {
907          xtype : 'HttpProxy',
908          method : 'GET',
909          url : baseURL + '/BAdmin/GroupRights.php',
910          xns : Roo.data,
911          '|xns' : 'Roo.data'
912         },
913         reader : {
914          xtype : 'JsonReader',
915          fields : [
916              {
917                  'name': 'id',
918                  'type': 'int'
919              },
920              {
921                  'name': 'rightname',
922                  'type': 'string'
923              },
924              {
925                  'name': 'descript',
926                  'type': 'string'
927              },
928              {
929                  'name': 'accessmask',
930                  'type': 'string'
931              },
932              {
933                  'name': 'FullMask',
934                  'type': 'string'
935              },
936              {
937                  'name': 'group_id',
938                  'type': 'int'
939              }
940          ],
941          id : 'id',
942          root : 'data',
943          totalProperty : 'total',
944          xns : Roo.data,
945          '|xns' : 'Roo.data'
946         }
947        },
948        sm : {
949         xtype : 'RowSelectionModel',
950         singleSelect : true,
951         xns : Roo.bootstrap.Table,
952         '|xns' : 'Roo.bootstrap.Table'
953        },
954        cm : [
955         {
956          xtype : 'ColumnModel',
957          align : 'center',
958          dataIndex : 'id',
959          header : _this._strings['17050e1914aff1e423a84e76db8ab0d1'] /* [All] */,
960          renderer : function (v,x,r) {
961              
962              if (!r.data.FullMask.length) {
963                  return '';
964              }
965              
966              var accessmask = r.data.accessmask.split('').sort().join('');
967              var fullmask = r.data.FullMask.split('').sort().join('');
968              
969              var state = (accessmask == fullmask) ? 'check-' : '';
970              
971              var cls = (accessmask == fullmask) ? 'text-primary' : '';
972              
973              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
974              
975          },
976          sortable : false,
977          xs : 1,
978          xns : Roo.grid,
979          '|xns' : 'Roo.grid'
980         },
981         {
982          xtype : 'ColumnModel',
983          dataIndex : 'rightname',
984          header : _this._strings['e55f75a29310d7b60f7ac1d390c8ae42'] /* Module */,
985          hidden : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 1 : 0,
986          renderer : function (v) {
987              return String.format('<span tooltip="{1}">{0}</span>', v.split('.').shift(), v);
988          },
989          xs : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 0 : 2,
990          xns : Roo.grid,
991          '|xns' : 'Roo.grid'
992         },
993         {
994          xtype : 'ColumnModel',
995          dataIndex : 'descript',
996          header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
997          renderer : function (v) {
998              return String.format('{0}', v ? v : '');
999          },
1000          xs : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 6 : 4,
1001          xns : Roo.grid,
1002          '|xns' : 'Roo.grid'
1003         },
1004         {
1005          xtype : 'ColumnModel',
1006          align : 'center',
1007          dataIndex : 'add',
1008          header : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
1009          renderer : function (v,x,r) {
1010              
1011              if (r.data.FullMask.indexOf('A') === -1) {
1012                  return '';
1013              }
1014              
1015              var state = (r.data.accessmask.indexOf('A') !== -1) ? 'check-' : '';
1016              var cls = (r.data.accessmask.indexOf('A') !== -1) ? 'text-primary' : '';
1017              
1018              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
1019          },
1020          sortable : false,
1021          xs : 1,
1022          xns : Roo.grid,
1023          '|xns' : 'Roo.grid'
1024         },
1025         {
1026          xtype : 'ColumnModel',
1027          align : 'center',
1028          dataIndex : 'edit',
1029          header : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
1030          renderer : function (v,x,r) {
1031              
1032              if (r.data.FullMask.indexOf('E') === -1) {
1033                  return '';
1034              }
1035              
1036              var state = (r.data.accessmask.indexOf('E') !== -1) ? 'check-' : '';
1037              var cls = (r.data.accessmask.indexOf('E') !== -1) ? 'text-primary' : '';
1038              
1039              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
1040          },
1041          sortable : false,
1042          xs : 1,
1043          xns : Roo.grid,
1044          '|xns' : 'Roo.grid'
1045         },
1046         {
1047          xtype : 'ColumnModel',
1048          align : 'center',
1049          dataIndex : 'delete',
1050          header : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
1051          renderer : function (v,x,r) {
1052              
1053              if (r.data.FullMask.indexOf('D') === -1) {
1054                  return '';
1055              }
1056              
1057              var state = (r.data.accessmask.indexOf('D') !== -1) ? 'check-' : '';
1058              var cls = (r.data.accessmask.indexOf('D') !== -1) ? 'text-primary' : '';
1059              
1060              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
1061              
1062          },
1063          sortable : false,
1064          xs : 1,
1065          xns : Roo.grid,
1066          '|xns' : 'Roo.grid'
1067         },
1068         {
1069          xtype : 'ColumnModel',
1070          align : 'center',
1071          dataIndex : 'view',
1072          header : _this._strings['f29c99f082755399839b64ebaf9f608a'] /* List / View */,
1073          renderer : function (v,x,r) {
1074              
1075              if (r.data.FullMask.indexOf('S') === -1) {
1076                  return '';
1077              }
1078              
1079              var state = (r.data.accessmask.indexOf('S') !== -1) ? 'check-' : '';
1080              var cls = (r.data.accessmask.indexOf('S') !== -1) ? 'text-primary' : '';
1081              
1082              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
1083              
1084          },
1085          sortable : false,
1086          xs : 1,
1087          xns : Roo.grid,
1088          '|xns' : 'Roo.grid'
1089         },
1090         {
1091          xtype : 'ColumnModel',
1092          align : 'center',
1093          dataIndex : 'print',
1094          header : _this._strings['4f3cdff2e6a5e08440be182ef40d93f7'] /* Print / Export */,
1095          renderer : function (v,x,r) {
1096              
1097              if (r.data.FullMask.indexOf('P') === -1) {
1098                  return '';
1099              }
1100              
1101              var state = (r.data.accessmask.indexOf('P') !== -1) ? 'check-' : '';
1102              var cls = (r.data.accessmask.indexOf('P') !== -1) ? 'text-primary' : '';
1103              
1104              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
1105              
1106          },
1107          sortable : false,
1108          xs : 1,
1109          xns : Roo.grid,
1110          '|xns' : 'Roo.grid'
1111         }
1112        ]
1113       }
1114      },
1115      {
1116       xtype : 'Grid',
1117       background : false,
1118       fitContainer : true,
1119       fitToFrame : true,
1120       region : 'west',
1121       title : _this._strings['a37ede293936e29279ed543129451ec3'] /* Groups */,
1122       listeners : {
1123        activate : function (_self)
1124         {
1125             if (_this.group_grid) {
1126                 _this.group_grid.store.load({});
1127             }
1128         },
1129        render : function (_self)
1130         {
1131             _this.group_panel = _self;
1132         }
1133       },
1134       xns : Roo.bootstrap.panel,
1135       '|xns' : 'Roo.bootstrap.panel',
1136       toolbar : {
1137        xtype : 'NavSimplebar',
1138        xns : Roo.bootstrap,
1139        '|xns' : 'Roo.bootstrap',
1140        items  : [
1141         {
1142          xtype : 'NavGroup',
1143          xns : Roo.bootstrap,
1144          '|xns' : 'Roo.bootstrap',
1145          items  : [
1146           {
1147            xtype : 'NavItem',
1148            cls : 'account-management-group-nav-item',
1149            xns : Roo.bootstrap,
1150            '|xns' : 'Roo.bootstrap',
1151            items  : [
1152             {
1153              xtype : 'Button',
1154              html : _this._strings['aba9f7d7443652e858969bfc280690b1'] /* Manage Groups */,
1155              xns : Roo.bootstrap,
1156              '|xns' : 'Roo.bootstrap',
1157              menu : {
1158               xtype : 'Menu',
1159               xns : Roo.bootstrap,
1160               '|xns' : 'Roo.bootstrap',
1161               items  : [
1162                {
1163                 xtype : 'MenuItem',
1164                 fa : 'fa fa-plus',
1165                 html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
1166                 isContainer : false,
1167                 preventDefault : true,
1168                 listeners : {
1169                  click : function (_self, e)
1170                   {
1171                       Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){
1172                           _this.group_grid.store.load({});
1173                       });
1174                   }
1175                 },
1176                 xns : Roo.bootstrap,
1177                 '|xns' : 'Roo.bootstrap'
1178                },
1179                {
1180                 xtype : 'MenuItem',
1181                 fa : 'fa fa-pencil',
1182                 html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
1183                 isContainer : false,
1184                 preventDefault : true,
1185                 listeners : {
1186                  click : function (_self, e)
1187                   {
1188                       var sel = _this.group_grid.getSelectionModel().getSelected();
1189                       
1190                       if(!sel){
1191                           Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
1192                           return;
1193                       }
1194                       
1195                       if(sel.data.id * 1 < 1){
1196                           Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
1197                           return;
1198                       }
1199                       
1200                       Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){
1201                           _this.group_grid.store.load({});
1202                       });
1203                   }
1204                 },
1205                 xns : Roo.bootstrap,
1206                 '|xns' : 'Roo.bootstrap'
1207                },
1208                {
1209                 xtype : 'MenuItem',
1210                 fa : 'fa fa-trash',
1211                 html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
1212                 isContainer : false,
1213                 preventDefault : true,
1214                 listeners : {
1215                  click : function (_self, e)
1216                   {
1217                       var sel = _this.group_grid.getSelectionModel().getSelected();
1218                       
1219                       if(!sel){
1220                           Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
1221                           return;
1222                       }
1223                       
1224                       if(sel.data.id * 1 < 1){
1225                           Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
1226                           return;
1227                       }
1228                       
1229                       var deleteIt = function()
1230                       {
1231                           new Pman.Request({
1232                               url: baseURL + '/Roo/Core_group',
1233                               method: 'POST',
1234                               params: {
1235                                   _delete : sel.data.id
1236                               },
1237                               success: function(res){
1238                                   _this.group_grid.store.load({});
1239                                   return;
1240                               }
1241                           });
1242                       }
1243                       
1244                       Roo.bootstrap.MessageBox.confirm('Confirm', 'Are you sure to delete the group?',function(ret) {
1245                           
1246                           if(ret == 'no'){
1247                               return;
1248                           }
1249                           
1250                           deleteIt();
1251                           
1252                        }, this);
1253                       
1254                       
1255                   }
1256                 },
1257                 xns : Roo.bootstrap,
1258                 '|xns' : 'Roo.bootstrap'
1259                },
1260                {
1261                 xtype : 'MenuItem',
1262                 fa : 'fa fa-refresh',
1263                 html : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
1264                 isContainer : false,
1265                 preventDefault : true,
1266                 listeners : {
1267                  click : function (_self, e)
1268                   {
1269                       _this.group_grid.store.load({});
1270                   }
1271                 },
1272                 xns : Roo.bootstrap,
1273                 '|xns' : 'Roo.bootstrap'
1274                }
1275               ]
1276              }
1277             }
1278            ]
1279           }
1280          ]
1281         }
1282        ]
1283       },
1284       grid : {
1285        xtype : 'Table',
1286        cls : 'table-fixed',
1287        footerShow : false,
1288        hover : true,
1289        loadMask : true,
1290        responsive : true,
1291        rowSelection : true,
1292        striped : true,
1293        listeners : {
1294         render : function (_self)
1295          {
1296              _this.group_grid = _self; 
1297          
1298              if (_this.group_panel.active) {
1299                  _this.group_grid.store.load({});
1300              }
1301          },
1302         rowdblclick : function (_self, el, rowIndex, e)
1303          {
1304              var sel = _this.group_grid.store.getAt(rowIndex);
1305              
1306              if(!sel || sel.data.id * 1 < 1){
1307                  return;
1308              }
1309              
1310              Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){
1311                  _this.group_grid.store.load({});
1312              });
1313          },
1314         rowsrendered : function (_self)
1315          {
1316              if(this.ds.getCount() * 1 < 1){
1317                  return;
1318              }
1319              
1320              var sm = _this.group_grid.getSelectionModel();
1321              
1322              sm.selectFirstRow();
1323              sm.fireEvent('afterselectionchange', sm);
1324              
1325          }
1326        },
1327        xns : Roo.bootstrap,
1328        '|xns' : 'Roo.bootstrap',
1329        store : {
1330         xtype : 'Store',
1331         remoteSort : true,
1332         sortInfo : { field: 'name', direction: 'ASC'},
1333         listeners : {
1334          beforeload : function (_self, options)
1335           {
1336               if (!Pman.buildCompleted) {
1337                   return false;
1338               }
1339               options.params = options.params || {};
1340               
1341               options.params.type = 0;
1342               
1343               options.params._add_everyone = 1;
1344           
1345           }
1346         },
1347         xns : Roo.data,
1348         '|xns' : 'Roo.data',
1349         proxy : {
1350          xtype : 'HttpProxy',
1351          method : 'GET',
1352          url : baseURL + '/Roo/core_group',
1353          xns : Roo.data,
1354          '|xns' : 'Roo.data'
1355         },
1356         reader : {
1357          xtype : 'JsonReader',
1358          fields : [
1359              {
1360                  'name': 'id',
1361                  'type': 'int'
1362              },
1363              {
1364                  'name': 'leader',
1365                  'type': 'string'
1366              },
1367              {
1368                  'name': 'group_member_count',
1369                  'type': 'int'
1370              },
1371              {
1372                  'name': 'display_name',
1373                  'type': 'string'
1374              },
1375              {
1376                  'name': 'name',
1377                  'type': 'string'
1378              }
1379          ],
1380          id : 'id',
1381          root : 'data',
1382          totalProperty : 'total',
1383          xns : Roo.data,
1384          '|xns' : 'Roo.data'
1385         }
1386        },
1387        sm : {
1388         xtype : 'RowSelectionModel',
1389         singleSelect : true,
1390         listeners : {
1391          afterselectionchange : function (_self)
1392           {
1393               if(_this.footerActiveBtn){
1394                   _this.footerActiveBtn.setActive(false);
1395                   _this.footerActiveBtn.fireEvent('toggle', _this.footerActiveBtn);
1396               }
1397               
1398               if(_this.permission_grid){
1399                   _this.permission_grid.store.load({});
1400               }
1401               
1402           }
1403         },
1404         xns : Roo.bootstrap.Table,
1405         '|xns' : 'Roo.bootstrap.Table'
1406        },
1407        cm : [
1408         {
1409          xtype : 'ColumnModel',
1410          cursor : 'pointer',
1411          dataIndex : 'name',
1412          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
1413          md : 12,
1414          renderer : function(v,x,r) { 
1415          
1416              if (r.data.id == 0) {
1417                  return '<b>' + "All Staff" + '</b>';
1418              }
1419              
1420              if (r.data.id == -1) {
1421                  return '<b>' + "Not in a Group" + '</b>';
1422              }
1423          
1424              var vv = (r.json.display_name.length) ? r.json.display_name : v;
1425              
1426              if (v == 'Administrators') {
1427                  return '<b>' + vv + '</b>';
1428              }
1429              
1430              if (r.data.leader) {
1431                  return vv + ' (' + r.json.leader_name + ')';
1432              }
1433              
1434              return String.format('{0} ({1})',vv, r.json.group_member_count);
1435          },
1436          sm : 12,
1437          sortable : false,
1438          xs : 12,
1439          xns : Roo.grid,
1440          '|xns' : 'Roo.grid'
1441         }
1442        ]
1443       }
1444      }
1445     ]
1446    }
1447   };  }
1448 });