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