PHP Classes
elePHPant
Icontem

File: app/design/adminhtml/default/default/template/braspress/system/config/validation.phtml

Recommend this page to a friend!
  Classes of Julio Cezar Kronbauer  >  Magento BrasPress  >  app/design/adminhtml/default/default/template/braspress/system/config/validation.phtml  >  Download  
File: app/design/adminhtml/default/default/template/braspress/system/config/validation.phtml
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Magento BrasPress
Magento extension to handle Braspress deliveries
Author: By
Last change:
Date: 4 years ago
Size: 1,988 bytes
 

 

Contents

Class file image Download
<script type="text/javascript">
    //<![CDATA[
    function validation() {
    	var elem = $('braspress_button');
    	
    	params = {
    		cnpj: $('carriers_braspress_cnpj').value
    	}
    	
        new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
			parameters: params,
            onSuccess: function(response){
            	var json = response.responseText.evalJSON();
            	result = 'Validado com sucesso';
 				try{
                	if(json.status == 'OK'){
                		elem.removeClassName('fail').addClassName('success');
                	}else{
                		elem.removeClassName('success').addClassName('fail');
                		result = json.msg;
                	}
            	}catch (e) {
					elem.removeClassName('success').addClassName('fail');
				}
				
				//alert(json.status);
				
				//alert(response ? Object.inspect(response) : "no JSON object");
				
				$('braspress_button').update(result);
            }
        });
    }
    
    
	function validateVat() {
		var elem = $('general_store_information_validate_vat_number');
		
		params = {
					country: $('general_store_information_merchant_country').value,
					vat: $('general_store_information_merchant_vat_number').value
				};

		new Ajax.Request('http://localhost/~tadeurodrigues/magento17/index.php/admin/customer_system_config_validatevat/validate/key/8c2fa7cdc826fc1e6446c9505201edf0/', {
				parameters: params,
				onSuccess: function(response) {
						result = 'VAT Number is Invalid';
						try {
							response = response.responseText;
							if (response == 1) {
								result = 'VAT Number is Valid';
								elem.removeClassName('fail').addClassName('success')
							} else {
								elem.removeClassName('success').addClassName('fail')
							}
						} catch (e) {
							elem.removeClassName('success').addClassName('fail')
						}
						$('validation_result').update(result);
				}
		});
	} 
    //]]>
</script>
 
<?php echo $this->getButtonHtml() ?>