interface/lib/classes/validate_client.inc.php | ●●●●● patch | view | raw | blame | history | |
interface/web/client/form/client.tform.php | ●●●●● patch | view | raw | blame | history | |
interface/web/client/form/reseller.tform.php | ●●●●● patch | view | raw | blame | history | |
interface/web/client/lib/lang/de_client.lng | ●●●●● patch | view | raw | blame | history | |
interface/web/client/lib/lang/de_reseller.lng | ●●●●● patch | view | raw | blame | history | |
interface/web/client/lib/lang/en_client.lng | ●●●●● patch | view | raw | blame | history | |
interface/web/client/lib/lang/en_reseller.lng | ●●●●● patch | view | raw | blame | history |
interface/lib/classes/validate_client.inc.php
@@ -136,7 +136,85 @@ } } function check_vat_id ($field_name, $field_value, $validator){ global $app, $page; $vatid = trim($field_value); if(isset($app->remoting_lib->primary_id)) { $country = $app->remoting_lib->dataRecord['country']; } else { $country = $page->dataRecord['country']; } // check if country is member of EU $country_details = $app->db->queryOneRecord("SELECT * FROM country WHERE iso = '".$country."'"); if($country_details['eu'] == 'y' && $vatid != ''){ $vatid = preg_replace('/\s+/', '', $vatid); $vatid = str_replace(array('.', '-', ','), '', $vatid); $cc = substr($vatid, 0, 2); $vn = substr($vatid, 2); // Test if the country of the VAT-ID matches the country of the customer if($country != ''){ if(strtoupper($cc) != $country){ $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { return $app->tform->wordbook[$errmsg]."<br>\r\n"; } else { return $errmsg."<br>\r\n"; } } } $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"); if($client){ $params = array('countryCode' => $cc, 'vatNumber' => $vn); try{ $r = $client->checkVat($params); if($r->valid == true){ } else { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { return $app->tform->wordbook[$errmsg]."<br>\r\n"; } else { return $errmsg."<br>\r\n"; } } // This foreach shows every single line of the returned information /* foreach($r as $k=>$prop){ echo $k . ': ' . $prop; } */ } catch(SoapFault $e) { //echo 'Error, see message: '.$e->faultstring; switch ($e->faultstring) { case 'INVALID_INPUT': $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { return $app->tform->wordbook[$errmsg]."<br>\r\n"; } else { return $errmsg."<br>\r\n"; } break; // the following cases shouldn't be the user's fault, so we return no error case 'SERVICE_UNAVAILABLE': case 'MS_UNAVAILABLE': case 'TIMEOUT': case 'SERVER_BUSY': break; } } } else { // Connection to host not possible, europe.eu down? // this shouldn't be the user's fault, so we return no error } } } } interface/web/client/form/client.tform.php
@@ -367,7 +367,12 @@ 'width' => '30', 'maxlength' => '255', 'rows' => '', 'cols' => '' 'cols' => '', 'validators' => array ( 0 => array ( 'type' => 'CUSTOM', 'class' => 'validate_client', 'function' => 'check_vat_id', 'errmsg'=> 'invalid_vat_id'), ), ), 'company_id' => array ( 'datatype' => 'VARCHAR', interface/web/client/form/reseller.tform.php
@@ -364,7 +364,12 @@ 'width' => '30', 'maxlength' => '255', 'rows' => '', 'cols' => '' 'cols' => '', 'validators' => array ( 0 => array ( 'type' => 'CUSTOM', 'class' => 'validate_client', 'function' => 'check_vat_id', 'errmsg'=> 'invalid_vat_id'), ), ), 'company_id' => array ( 'datatype' => 'VARCHAR', interface/web/client/lib/lang/de_client.lng
@@ -110,7 +110,7 @@ $wb['limit_backup_txt'] = 'Backupfunktion verfügbar'; $wb['limit_dns_slave_zone_error_notint'] = 'Das Secondary DNS Zonen Limit muss eine Zahl sein.'; $wb['customer_no_txt'] = 'Kundennummer'; $wb['vat_id_txt'] = 'USt-ID'; $wb['vat_id_txt'] = 'USt.-ID'; $wb['required_fields_txt'] = '* Benötigte Felder'; $wb['limit_mailmailinglist_txt'] = 'Max. Anzahl an Mailinglisten'; $wb['limit_mailmailinglist_error_notint'] = 'Das Mailinglisten Limit muss eine Zahl sein.'; @@ -176,4 +176,5 @@ $wb['reseller_txt'] = 'Reseller'; $wb['btn_save_txt'] = 'Speichern'; $wb['btn_cancel_txt'] = 'Abbrechen'; $wb['invalid_vat_id'] = 'Die USt.-ID ist ungültig.'; ?> interface/web/client/lib/lang/de_reseller.lng
@@ -106,7 +106,7 @@ $wb['limit_dns_slave_zone_error_notint'] = 'Das Secondary DNS Zonen Limit muss eine Zahl sein.'; $wb['limit_dns_record_error_notint'] = 'Das DNS Eintrag Limit muss eine Zahl sein.'; $wb['customer_no_txt'] = 'Kundennummer'; $wb['vat_id_txt'] = 'USt-ID'; $wb['vat_id_txt'] = 'USt.-ID'; $wb['required_fields_txt'] = '* Benötigte Felder'; $wb['limit_webdav_user_txt'] = 'Max. Anzahl an WebDAV Benutzern'; $wb['limit_webdav_user_error_notint'] = 'Das WebDAV Benutzer Limit muss eine Zahl sein.'; @@ -160,4 +160,5 @@ $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; $wb['client_limits_txt'] = 'Client Limits'; $wb['err_msg_master_tpl_set'] = 'All custom limit settings are ignored if any master template other than \\"custom\\" is selected.'; $wb['invalid_vat_id'] = 'Die USt.-ID ist ungültig.'; ?> interface/web/client/lib/lang/en_client.lng
@@ -179,4 +179,5 @@ $wb['reseller_txt'] = 'Reseller'; $wb['btn_save_txt'] = "Save"; $wb['btn_cancel_txt'] = "Cancel"; $wb['invalid_vat_id'] = 'The VAT ID is invalid.'; ?> interface/web/client/lib/lang/en_reseller.lng
@@ -178,4 +178,5 @@ $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; $wb['client_limits_txt'] = 'Client Limits'; $wb['err_msg_master_tpl_set'] = 'All custom limit settings are ignored if any master template other than "custom" is selected.'; $wb['invalid_vat_id'] = 'The VAT ID is invalid.'; ?>