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