DataObjects/Core_person.php
[Pman.Core] / Pman.Dialog.CoreCompanies.js
index 7368828..3f6f3e5 100644 (file)
@@ -100,36 +100,41 @@ Pman.Dialog.CoreCompanies = {
       listeners : {
        click : function (_self, e)
         {
-            // do some checks?
-            
             if(!_this.form.isValid()){
                 Roo.MessageBox.alert('Error', 'Please Correct all the errors in red');
                 return;
             }
             
             new Pman.Request({
-                url : baseURL + '/Roo/Core_enum.php',
+                url : baseURL + '/Roo/Core_company.php',
                 method : 'POST',
                 params : {
-                  id : record.data.id,
-                  etype : _this.data.etype,
-                  name :  record.data.name,
-                  active : record.data.active,
-                  seqid : record.data.seqid,
-                  display_name : record.data.display_name
+                  id : _this.form.findField('id').getValue() * 1,
+                  name : _this.form.findField('name').getValue(),
+                  _check_name : 1
                 }, 
                 success : function(res) {
-                  //Roo.log(data);
-                  // update the ID if it's not set..
-                  if (record.data.id * 1 < 1) {
-                      record.set('id', res.data.id);
-                  }
+                    _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");
+                        }
+                    );
                 }
             });
             
-            _this.dialog.el.mask("Saving");
-            _this.form.doAction("submit");
-        
+            return;
+            
         }
       },
       xns : Roo,
@@ -149,7 +154,7 @@ Pman.Dialog.CoreCompanies = {
         xtype : 'Form',
         fileUpload : true,
         labelWidth : 160,
-        url : baseURL + '/Roo/Companies.php',
+        url : baseURL + '/Roo/core_company.php',
         listeners : {
          actioncomplete : function(f, act) {
               _this.dialog.el.unmask();
@@ -394,7 +399,7 @@ Pman.Dialog.CoreCompanies = {
                                        
                   Pman.Dialog.Image.show({
                       onid :_this.data.id,
-                      ontable : 'Companies',
+                      ontable : 'core_company',
                       imgtype : 'LOGO'
                   }, function(data) {
                       if  (data) {