Pman.Gnumeric.js
[Pman.Core] / Pman.Dialog.PersonEditor.js
index 7461c0d..2cee8c0 100644 (file)
@@ -37,7 +37,7 @@ Pman.Dialog.PersonEditor.prototype = {
                 title: 'Edit Contact Details',
                 modal: true,
                 width:  530,
-                height: 300,
+                height: 400,
                 shadow:true,
                 minWidth:200,
                 minHeight:180,
@@ -81,8 +81,8 @@ Pman.Dialog.PersonEditor.prototype = {
                 actioncomplete: function(f, act) {
                     _this.dialog.el.unmask();
                     if (act.type == 'load') {
+                        
                         _this.data = act.result.data;
-                         
                     }
                     
                                 
@@ -90,6 +90,9 @@ Pman.Dialog.PersonEditor.prototype = {
                         var data = _this.data;
                         // we dont have  a form where company name is sent in - and is editable..
                         //this.form.findField('office_id')
+                        if(!data.countries && _this.form.findField('countries')){
+                            _this.form.findField('countries').setValue();// set empty array by default...
+                        }
                         
                         if (_this.form.findField('company_id') && _this.form.findField('company_id').setFromData) {
                             _this.form.findField('company_id').setFromData( data.company_id ? {
@@ -140,6 +143,8 @@ Pman.Dialog.PersonEditor.prototype = {
                             }
 
                         }
+                        
+                        
                         return;
                     } 
                     
@@ -167,10 +172,16 @@ Pman.Dialog.PersonEditor.prototype = {
         this.loadItemTypes();
         Roo.each(this.itemList, function(il) {
             if (typeof(il) != 'object') {
+                // no permission for Core offices.. - can not show department...
+                if (il == 'office_id_name' && !Pman.hasPerm('Core.Offices','S')) {
+                    return true;
+                }
+                
                 _this.form.addxtype(_this.itemTypes[il]);
                 return true;
             }
             _this.form.addxtype(Roo.apply(il, _this.itemTypes[il.name]));
+            return true;
             
         });
         var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
@@ -224,15 +235,15 @@ Pman.Dialog.PersonEditor.prototype = {
                       // load using HTTP
                     proxy:{
                         xtype:  'HttpProxy',
-                        url: baseURL + '/Roo/Companies.html',
+                        url: baseURL + '/Roo/core_company',
                         method: 'GET'
                     },
-                    reader: Pman.Readers.Companies,
+                    reader: new Roo.data.JsonReader({}, []), //Pman.Readers.Companies,
                     listeners : {
                         beforeload : function(st,o)
                         {
                         
-                            o.params.isOwner = 0;
+                            o.params['!comptype'] = 'OWNER';
                         },
                         loadexception : Pman.loadException
                     
@@ -253,7 +264,7 @@ Pman.Dialog.PersonEditor.prototype = {
                         '<b>{name}</b> {address}',
                     '</div>'
                 ),
-                queryParam: 'query[name]',
+                queryParam: 'search[name_starts]',
                 loadingText: "Searching...",
                 listWidth: 400,
                
@@ -263,7 +274,7 @@ Pman.Dialog.PersonEditor.prototype = {
                     adderclick : function()
                     {
                         var cb = this;
-                        Pman.Dialog.Companies.show( {  id: 0 },  function(data) {
+                        Pman.Dialog.CoreCompanies.show( {  id: 0 },  function(data) {
                             cb.setFromData(data);
                         }); 
                     }
@@ -297,10 +308,10 @@ Pman.Dialog.PersonEditor.prototype = {
                       // load using HTTP
                     proxy: {
                         xtype : 'HttpProxy',
-                        url: baseURL + '/Roo/Office.html',
+                        url: baseURL + '/Roo/Core_office.html',
                         method: 'GET'
                     },
-                    reader: Pman.Readers.Office,
+                    reader: new Roo.data.JsonReader({}, []), //Pman.Readers.Office,
                     listeners : {
                         beforeload : function(st,o)
                         {
@@ -455,12 +466,43 @@ Pman.Dialog.PersonEditor.prototype = {
                 xtype : 'TextField',
                 width : 300
             },
+            countries : {
+                xtype: 'ComboBoxArray',
+                xns: Roo.form,
+                fieldLabel : 'Country',
+                hiddenName : 'countries',
+                name : 'countries_name',
+                width : 300,
+                combo : {
+                    xtype: 'ComboBox',
+                    xns: Roo.form,
+                    allowBlank : true,
+                    alwaysQuery : true,
+                    displayField : 'title',
+                    editable : false,
+                    emptyText : "Select Country",
+                    forceSelection : true,
+                    idField : 'id',
+                    triggerAction : 'all',
+                    typeAhead : true,
+                    valueField : 'code',
+                    width : 280,
+                    store : {
+                        xtype: 'SimpleStore',
+                        xns: Roo.data,
+                        data : (function() {
+                            return Pman.I18n.simpleStoreData('c');
+                        })(),
+                        fields : [  'code', 'title' ]
+                    }
+                }
+            },
             passwd1 : {
                 name : 'passwd1',
                 fieldLabel : "New Password ",
                 value : '',
                 allowBlank : true, // must be filled in as we rely on it for login details..
-                inputType: 'password',
+                inputType: 'password', // << if comment out this input type, it should be ok
                 xtype : 'SecurePass',
                 width : 220,
                 imageRoot : rootURL + '/Pman/templates/images'
@@ -471,10 +513,29 @@ Pman.Dialog.PersonEditor.prototype = {
                 fieldLabel : "Password (type again to confirm)",
                 value : '',
                 allowBlank : true, // must be filled in as we rely on it for login details..
-                inputType: 'password',
+                inputType: 'password', // << if comment out this input type, it should be ok
                 xtype : 'TextField',
                 width : 220
             },
+            secure_password : {
+                name : 'secure_password',
+                fieldLabel : "Secure passwords",
+                inputValue : 1,
+                valueOff : 0,
+                checked : true,
+                xtype : 'Checkbox',
+                xns : Roo.form,
+                width : 220,
+                listeners : {
+                    check : function (_self, checked) {
+                        this.form.findField('passwd1').insecure = false;
+                        
+                        if(!checked){
+                            this.form.findField('passwd1').insecure = true;
+                        }
+                    }
+                }
+            },
             project_id_fs : {
                 xtype : 'FieldSetEx',
                 name: 'project_id_fs',
@@ -551,7 +612,7 @@ Pman.Dialog.PersonEditor.prototype = {
             return;
             
         }
-        if (!this.form.findField('company_id').getValue()) {
+        if (this.form.findField('company_id') && !this.form.findField('company_id').getValue()) {
             Ext.MessageBox.alert("Error", "Select a Company");
             return;
         }
@@ -592,7 +653,7 @@ Pman.Dialog.PersonEditor.prototype = {
         }
         this.dialog.el.mask("Sending");
         this.form.doAction('submit', {
-            url: baseURL + '/Roo/Person.html',
+            url: baseURL + '/Roo/core_person',
             method: 'POST',
             params: {
                 _id: this._id ,
@@ -615,7 +676,7 @@ Pman.Dialog.PersonEditor.prototype = {
             this.dialog.show();
             this.dialog.el.mask("Loading");
             this.form.doAction('load', {
-                url: baseURL + '/Roo/Person.html',
+                url: baseURL + '/Roo/core_person',
                 method: 'GET',
                 params: {
                     _id: this._id ,
@@ -641,8 +702,7 @@ Pman.Dialog.PersonEditor.prototype = {
     saveBulk: function() {
         // similar action to SendIntro
         // we build a fake list of data..
-        if (this.form.findField('company_id') && 
-                !this.form.findField('company_id').getValue()) {
+        if (!this.form.findField('company_id').getValue()) {
             Roo.MessageBox.alert("Error", "Select the Company Name");
             return;
         }
@@ -721,7 +781,7 @@ Pman.Dialog.PersonEditor.prototype = {
              
             var c = ar[i];
             i++;
-            Pman.request({
+            new Pman.Request({
                 url : baseURL+'/Core/SendIntro.html',
                 method : 'POST',
                 params: c,