check file exists
[Pman.Core] / Pman.Dialog.CoreCompanies.js
index fd85277..e44744a 100644 (file)
@@ -34,6 +34,30 @@ Pman.Dialog.CoreCompanies = {
   '35cb9e66ff801a819684ee0fbeabaeeb' :"Background Colour",
   'bc87ef2144ae15ef4f78211e73948051' :"Logo Image"
  },
+ _named_strings : {
+  'name_qtip' : '4ef6052d74436756f08e95fd63949653' /* Enter Company Name */ ,
+  'tel_fieldLabel' : 'bcc254b55c4a1babdf1dcb82c207506b' /* Phone */ ,
+  'address_qtip' : '32c4e9483403d60115b21519178e5384' /* Enter Address */ ,
+  'background_color_fieldLabel' : '35cb9e66ff801a819684ee0fbeabaeeb' /* Background Colour */ ,
+  'comptype_id_display_name_emptyText' : '023a5dfa857c4aa0156e6685231a1dbd' /* Select Type */ ,
+  'comptype_id_display_name_fieldLabel' : 'a1fa27779242b4902f7ae3bdd5c6d508' /* Type */ ,
+  'comptype_id_display_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
+  'code_fieldLabel' : 'b33457e7e1cd5dbf1db34a0c60fcb75f' /* Company ID (for filing Ref.) */ ,
+  'fax_fieldLabel' : '9810aa2b9f44401be4bf73188ef2b67d' /* Fax */ ,
+  'name_fieldLabel' : 'e7b47c58815acf1d3afa59a84b5db7fb' /* Company Name */ ,
+  'fax_qtip' : 'cf3a5d25d39613ad5bbc2f5eb0f9b675' /* Enter Fax Number */ ,
+  'url_qtip' : '8c04eb09879a05470fae436ba76e3bb9' /* Enter Url */ ,
+  'remarks_fieldLabel' : '231bc72756b5e6de492aaaa1577f61b1' /* Remarks */ ,
+  'code_qtip' : '733640ec0c9367df1b4d85eb286ed9ae' /* Enter code */ ,
+  'tel_qtip' : 'bc3a4c40d007b8d610a16312970e5cb3' /* Enter Phone Number */ ,
+  'email_qtip' : '9f86c00615b1a210935ac28ff8ebbb22' /* Enter Email Address */ ,
+  'url_fieldLabel' : '02a3a357710cc2a5dfdfb74ed012fb59' /* Url */ ,
+  'remarks_qtip' : 'c54b90756cfbeff9217293b567cb2eb0' /* Enter remarks */ ,
+  'comptype_id_display_name_qtip' : '8535bcc0f05358a583bb432bbadf7e0d' /* Select type */ ,
+  'email_fieldLabel' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
+  'address_fieldLabel' : 'dd7bf230fde8d4836917806aff6a6b27' /* Address */ ,
+  'logo_id_fieldLabel' : 'bc87ef2144ae15ef4f78211e73948051' /* Logo Image */ 
+ },
 
  dialog : false,
  callback:  false,
@@ -100,15 +124,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;
             }
             
-            _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,
@@ -128,7 +178,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();
@@ -195,16 +245,17 @@ Pman.Dialog.CoreCompanies = {
            },
            {
             xtype : 'ComboBox',
+            allowBlank : false,
             alwaysQuery : true,
             displayField : 'display_name',
             emptyText : _this._strings['023a5dfa857c4aa0156e6685231a1dbd'] /* Select Type */,
             fieldLabel : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
             forceSelection : true,
-            hiddenName : 'comptype',
+            hiddenName : 'comptype_id',
             listWidth : 250,
             loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
             minChars : 2,
-            name : 'comptype_display_name',
+            name : 'comptype_id_display_name',
             pageSize : 20,
             qtip : _this._strings['8535bcc0f05358a583bb432bbadf7e0d'] /* Select type */,
             queryParam : 'query[name]',
@@ -212,7 +263,7 @@ Pman.Dialog.CoreCompanies = {
             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> : {display_name}</div>',
             triggerAction : 'all',
             typeAhead : false,
-            valueField : 'name',
+            valueField : 'id',
             width : 200,
             listeners : {
              render : function (_self)
@@ -372,7 +423,7 @@ Pman.Dialog.CoreCompanies = {
                                        
                   Pman.Dialog.Image.show({
                       onid :_this.data.id,
-                      ontable : 'Companies',
+                      ontable : 'core_company',
                       imgtype : 'LOGO'
                   }, function(data) {
                       if  (data) {