PHP8
[Pman.BAdmin] / Pman.Tab.BAdminCompany.js
index 9b4ba30..a05e374 100644 (file)
@@ -9,14 +9,14 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
  _strings : {
   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
   '231bc72756b5e6de492aaaa1577f61b1' :"Remarks",
-  'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
   'edefbda3a2bdd979e42d8944b7325b79' :"Companies",
   'b80bb7740288fda1f201890375a60c8f' :"id",
-  '7dce122004969d56ae2e0245cb754d35' :"Edit",
   'fc6f97505d89fe9277965c126744647a' :"No Companies found",
+  '694e249c3a9503141fa5ce3fb71d5477' :"<i class=\"fa fa-edit\"></i> Edit",
   '155ca6a755e25c15ad7ce45e2f638f10' :"Displaying Companies{0} - {1} of {2}",
+  'fd5293a712d172f5c556a83c62d44bd6' :"<i class=\"fa fa-plus\"></i> Add",
+  'ed807858fcb68abdd180481f1fcba5c5' :"<i class=\"fa fa-trash\"></i> Delete",
   'f78e208016407d8756c29673558ac14d' :"Company List",
-  'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
   '9c9745a343efeacc9efe9b7222b27afb' :"Ref#",
   '49ee3087348e8d44e1feda1917443987' :"Name",
@@ -24,11 +24,15 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
   'dd7bf230fde8d4836917806aff6a6b27' :"Address",
   '9810aa2b9f44401be4bf73188ef2b67d' :"Fax"
  },
+ _named_strings : {
+  'footer_displayMsg' : '155ca6a755e25c15ad7ce45e2f638f10' /* Displaying Companies{0} - {1} of {2} */ ,
+  'footer_emptyMsg' : 'fc6f97505d89fe9277965c126744647a' /* No Companies found */ 
+ },
 
   part     :  ["BAdmin", "Company" ],
   order    : '002-Pman.Tab.BAdminCompany',
   region   : 'center',
-  parent   : 'Pman.Tab',
+  parent   : 'Pman.Tab.BAdmin',
   name     : "unnamed module",
   disabled : false, 
   permname : '', 
@@ -38,6 +42,7 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
    var MODULE = this;
    return {
    xtype : 'Nest',
+   background : false,
    region : 'center',
    title : _this._strings['edefbda3a2bdd979e42d8944b7325b79'] /* Companies */,
    xns : Roo.bootstrap.panel,
@@ -48,6 +53,7 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
     '|xns' : 'Roo.bootstrap.layout',
     center : {
      xtype : 'Region',
+     tabPosition : 'top',
      xns : Roo.bootstrap.layout,
      '|xns' : 'Roo.bootstrap.layout'
     },
@@ -61,11 +67,12 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
       listeners : {
        activate : function (_self)
         {
-         
+            _this.edit_btn.hide();
+            _this.delete_btn.hide();
+            
             if (_this.table) {
-              _this.table.store.load({});
-              _this.dialog = Pman.Dialog.BAdminCompany;
-              }
+                _this.table.footer.onClick('first');
+            }
         },
        render : function (_self)
         {
@@ -86,75 +93,104 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
          items  : [
           {
            xtype : 'NavItem',
-           style : 'float: left',
            xns : Roo.bootstrap,
            '|xns' : 'Roo.bootstrap',
            items  : [
             {
-             xtype : 'Button',
-             html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
-             style : 'margin: 10px;',
-             weight : 'primary',
-             listeners : {
-              click : function (_self, e)
-               {
-                   if (!_this.dialog) {
-                       return;
-                       }
-               
-                   _this.dialog.show({}, function() {
-                       if (_this.table) {
-                           _this.table.store.load({});
-                       }
-                   }); 
-                   _this.dialog.modal.setTitle('Add Company');
-                   _this.dialog.form.reset();
-               
-               }
-             },
-             xns : Roo.bootstrap,
-             '|xns' : 'Roo.bootstrap'
-            },
-            {
-             xtype : 'Button',
-             html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
-             style : 'margin: 10px;',
-             weight : 'primary',
-             listeners : {
-              click : function (_self, e)
-               {
-                   var s = _this.grid.grid.selModel.getSelections();
-                   if (!s.length || (s.length > 1))  {
-                       Roo.bootstrap.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
-                       return;
-                   }
-                   if (!_this.dialog) {
-                       return;
-                   }
-                   _this.dialog.show(s[0].data, function() {
-                       if (_this.table) {
-                           _this.table.store.load({});
-                       }
-                   }); 
-                   
-               }
-             },
-             xns : Roo.bootstrap,
-             '|xns' : 'Roo.bootstrap'
-            },
-            {
-             xtype : 'Button',
-             html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
-             style : 'margin: 10px;',
-             weight : 'primary',
-             listeners : {
-              click : function (_self, e)
-               {
-                     Pman.genericDelete(_this.grid, 'core_company'); 
-               }
-             },
+             xtype : 'Element',
              xns : Roo.bootstrap,
-             '|xns' : 'Roo.bootstrap'
+             '|xns' : 'Roo.bootstrap',
+             items  : [
+              {
+               xtype : 'Row',
+               cls : 'roo-toolbar',
+               xns : Roo.bootstrap,
+               '|xns' : 'Roo.bootstrap',
+               items  : [
+                {
+                 xtype : 'Column',
+                 md : 12,
+                 xns : Roo.bootstrap,
+                 '|xns' : 'Roo.bootstrap',
+                 items  : [
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   html : _this._strings['fd5293a712d172f5c556a83c62d44bd6'] /* <i class="fa fa-plus"></i> Add */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         Pman.Dialog.BAdminCompany.show({}, function() {
+                             if (_this.table) {
+                                 _this.table.footer.onClick('first');
+                             }
+                         }); 
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  },
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   html : _this._strings['694e249c3a9503141fa5ce3fb71d5477'] /* <i class="fa fa-edit"></i> Edit */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         var s = _this.table.getSelectionModel().getSelected();
+                             
+                         if (!s || s.data.id * 1 < 1)  {
+                             Roo.bootstrap.MessageBox.alert("Error", 'Please select a company');
+                             return;
+                         }
+                         
+                         Pman.Dialog.BAdminCompany.show({
+                             id : s.data.id
+                         }, function() {
+                             if (_this.table) {
+                                 _this.table.footer.onClick('refresh');
+                             }
+                         });
+                         
+                         
+                     },
+                    render : function (_self)
+                     {
+                         _this.edit_btn = this;
+                         
+                         this.hide();
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  },
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   html : _this._strings['ed807858fcb68abdd180481f1fcba5c5'] /* <i class="fa fa-trash"></i> Delete */,
+                   weight : 'primary',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         Pman.genericDelete(_this.grid, 'core_company'); 
+                     },
+                    render : function (_self)
+                     {
+                         _this.delete_btn = this;
+                         
+                         this.hide();
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  }
+                 ]
+                }
+               ]
+              }
+             ]
             }
            ]
           }
@@ -167,41 +203,54 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
        cls : 'table-fixed',
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : false,
        listeners : {
         render : function (_self)
          {
-           _this.table = _self;
-           
-           
-           if(_this.table.active) {
-             this.footer.onClick('first');
-           }
+             _this.table = this;
+         },
+        rowclick : function (_self, el, rowIndex, e)
+         {
+             (function(){
+                 
+                 _this.edit_btn.hide();
+                 _this.delete_btn.hide();
+                 
+                 var s = _this.table.getSelectionModel().getSelected();
+                 
+                 if (!s || s.data.id * 1 < 1)  {
+                     return;
+                 }
+                 
+                 _this.edit_btn.show();
+                 _this.delete_btn.show();
+                 
+             }).defer(100);
+             
          },
         rowdblclick : function (_self, el, rowIndex, e)
          {
-             var s = _this.grid.grid.selModel.getSelections();
-             if (!s.length || (s.length > 1))  {
-                 Roo.bootstrap.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
+             var s = _this.table.store.getAt(rowIndex);
+             
+             if(!s || s.data.id * 1 < 1){
                  return;
              }
-             if (!_this.dialog) {
-                 return;
-             }
-             _this.dialog.show(s[0].data, function() {
+             
+             Pman.Dialog.BAdminCompany.show({
+                 id : s.data.id
+             }, function() {
                  if (_this.table) {
-                     _this.table.store.load({});
+                     _this.table.footer.onClick('refresh');
                  }
-             });  
+             });
          }
        },
        xns : Roo.bootstrap,
        '|xns' : 'Roo.bootstrap',
        footer : {
         xtype : 'PagingToolbar',
-        displayInfo : true,
+        displayInfo : false,
         displayMsg : _this._strings['155ca6a755e25c15ad7ce45e2f638f10'] /* Displaying Companies{0} - {1} of {2} */,
         emptyMsg : _this._strings['fc6f97505d89fe9277965c126744647a'] /* No Companies found */,
         name : 'footer',
@@ -222,18 +271,18 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
         rowSelection : true,
         striped : true,
         listeners : {
-         rowclick : function (_self, el, rowIndex, e)
+         beforeload : function (_self, options)
           {
-              alert('hit');
-              rowElId = el.id;
-              //var rowId = document.getElementById(rowElId).childNodes[0].innerHTML;
-              var rowType = document.getElementById(rowElId).childNodes[1].innerHTML;
-              var rowRef = document.getElementById(rowElId).childNodes[2].innerHTML;
-              var rowName = document.getElementById(rowElId).childNodes[3].innerHTML;
-              //var rowTel = document.getElementById(rowElId).childNodes[4].innerHTML;
-              //var rowFax = document.getElementById(rowElId).childNodes[5].innerHTML;
-              Pman.Dialog.CompanyModify.show({});
+               if (!Pman.buildCompleted) {
+                  return false;
+              }
               
+              options.params = options.params || {};
+          },
+         load : function (_self, records, options)
+          {
+              _this.delete_btn.hide();
+              _this.edit_btn.hide();
           }
         },
         xns : Roo.data,
@@ -260,87 +309,112 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
          '|xns' : 'Roo.data'
         }
        },
+       sm : {
+        xtype : 'RowSelectionModel',
+        singleSelect : true,
+        xns : Roo.bootstrap.Table,
+        '|xns' : 'Roo.bootstrap.Table'
+       },
        cm : [
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'comptype',
          header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
+         md : 1,
          renderer : function (v,x ,r) {
              //return Pman.Dialog.Companies.comptypeListToString(r.data.isOwner ? 'OWNER' : v);
              return v;
          },
+         sm : 1,
          sortable : true,
-         width : 90,
+         xs : 1,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'code',
          header : _this._strings['9c9745a343efeacc9efe9b7222b27afb'] /* Ref# */,
+         hidden : true,
          renderer : function(v) { return String.format('{0}', v); },
          sortable : true,
-         width : 50,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'name',
          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
+         md : 2,
          renderer : function(v,x,r) {
              return String.format(r.data.comptype == 'OWNER' ? '<B>{0}</B>' : '{0}',v);    
          },
+         sm : 2,
          sortable : true,
-         width : 200,
+         xs : 2,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'tel',
          header : _this._strings['2e006b735fbd916d8ab26978ae6714d4'] /* Tel */,
+         md : 1,
          renderer : function(v) { return String.format('{0}', v); },
-         width : 100,
+         sm : 1,
+         xs : 1,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'fax',
          header : _this._strings['9810aa2b9f44401be4bf73188ef2b67d'] /* Fax */,
+         md : 1,
          renderer : function(v) { return String.format('{0}', v); },
-         width : 100,
+         sm : 1,
+         xs : 1,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'email',
          header : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
+         md : 2,
          renderer : function (v) {
-                 console.log('render:' + v);
                  return (v.length && v.indexOf('@') > 0 ) ? 
                      String.format('<a href="mailto:{0}">{0}</a>',v) : v;
                      
              },
+         sm : 2,
          sortable : true,
-         width : 200,
+         xs : 2,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'address',
          header : _this._strings['dd7bf230fde8d4836917806aff6a6b27'] /* Address */,
+         md : 5,
          renderer : function(v) { return String.format('{0}', v); },
+         sm : 5,
          sortable : true,
-         width : 250,
+         xs : 5,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'remarks',
          header : _this._strings['231bc72756b5e6de492aaaa1577f61b1'] /* Remarks */,
          hidden : true,
@@ -351,6 +425,7 @@ Pman.Tab.BAdminCompany = new Roo.XComponent({
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'id',
          header : _this._strings['b80bb7740288fda1f201890375a60c8f'] /* id */,
          hidden : true,