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