DataObjects/Core_company.php
[Pman.Core] / Pman.Dialog.CoreCompanies.js
index b131aa9..9ceef5e 100644 (file)
@@ -100,15 +100,41 @@ Pman.Dialog.CoreCompanies = {
       listeners : {
        click : function (_self, e)
         {
-            // do some checks?
-            
             if(!_this.form.isValid()){
-                Roo.
+                Roo.MessageBox.alert('Error', 'Please Correct all the errors in red');
+                return;
             }
             
-            _this.dialog.el.mask("Saving");
-            _this.form.doAction("submit");
-        
+            new Pman.Request({
+                url : baseURL + '/Roo/Core_company.php',
+                method : 'POST',
+                params : {
+                  id : _this.form.findField('id').getValue() * 1,
+                  name : _this.form.findField('name').getValue(),
+                  _check_name : 1
+                }, 
+                success : function(res) {
+                    _this.dialog.el.mask("Saving");
+                    _this.form.doAction("submit");
+                },
+                failure : function(res) {
+                    Roo.MessageBox.confirm(
+                        "Confirm", 
+                        "The company name has been used. Save it anyway?", 
+                        function(res) {
+                            if(res != 'yes') {
+                                return;
+                            }
+                            
+                            _this.dialog.el.mask("Saving");
+                            _this.form.doAction("submit");
+                        }
+                    );
+                }
+            });
+            
+            return;
+            
         }
       },
       xns : Roo,
@@ -195,6 +221,7 @@ Pman.Dialog.CoreCompanies = {
            },
            {
             xtype : 'ComboBox',
+            allowBlank : false,
             alwaysQuery : true,
             displayField : 'display_name',
             emptyText : _this._strings['023a5dfa857c4aa0156e6685231a1dbd'] /* Select Type */,