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