diff --git a/modules/addons/gofasnfeio/hooks/aftercronjob.php b/modules/addons/gofasnfeio/hooks/aftercronjob.php index 64239d5..1e3e141 100644 --- a/modules/addons/gofasnfeio/hooks/aftercronjob.php +++ b/modules/addons/gofasnfeio/hooks/aftercronjob.php @@ -4,6 +4,7 @@ exit(); } use WHMCS\Database\Capsule; + if ($params['debug']) { logModuleCall('gofas_nfeio', 'check', 'check', '', 'replaceVars'); } @@ -72,7 +73,15 @@ } else { $desc = substr(implode("\n", $line_items), 0, 600); } - + if (strpos($client['address1'], ',')) { + $array_adress=explode(",", $client['address1']); + $street = $array_adress[0]; + $number=$array_adress[1]; + } else { + $street = str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])); + $number=preg_replace('/[^0-9]/', '', $client['address1']); + } + if (0 == !strlen($customer['insc_municipal'])) { $postfields = [ 'cityServiceCode' => $service_code, @@ -86,8 +95,8 @@ 'address' => [ 'country' => gnfe_country_code($client['countrycode']), 'postalCode' => preg_replace('/[^0-9]/', '', $client['postcode']), - 'street' => str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])), - 'number' => preg_replace('/[^0-9]/', '', $client['address1']), + 'street' => $street, + 'number' => $number, 'additionalInformation' => '', 'district' => $client['address2'], 'city' => [ @@ -112,8 +121,8 @@ 'address' => [ 'country' => gnfe_country_code($client['countrycode']), 'postalCode' => preg_replace('/[^0-9]/', '', $client['postcode']), - 'street' => str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])), - 'number' => preg_replace('/[^0-9]/', '', $client['address1']), + 'street' => $street, + 'number' => $number, 'additionalInformation' => '', 'district' => $client['address2'], 'city' => [ diff --git a/modules/addons/gofasnfeio/hooks/dailycronjob.php b/modules/addons/gofasnfeio/hooks/dailycronjob.php index 5191f36..9b7422f 100644 --- a/modules/addons/gofasnfeio/hooks/dailycronjob.php +++ b/modules/addons/gofasnfeio/hooks/dailycronjob.php @@ -54,6 +54,15 @@ } else { $desc = substr(implode("\n", $line_items), 0, 600); } + if (strpos($client['address1'], ',')) { + $array_adress=explode(",", $client['address1']); + $street = $array_adress[0]; + $number=$array_adress[1]; + } else { + $street = str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])); + $number=preg_replace('/[^0-9]/', '', $client['address1']); + } + if (0 == !strlen($customer['insc_municipal'])) { $postfields = [ 'cityServiceCode' => $service_code, @@ -67,8 +76,8 @@ 'address' => [ 'country' => gnfe_country_code($client['countrycode']), 'postalCode' => preg_replace('/[^0-9]/', '', $client['postcode']), - 'street' => str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])), - 'number' => preg_replace('/[^0-9]/', '', $client['address1']), + 'street' => $street, + 'number' => $number, 'additionalInformation' => '', 'district' => $client['address2'], 'city' => [ @@ -93,8 +102,8 @@ 'address' => [ 'country' => gnfe_country_code($client['countrycode']), 'postalCode' => preg_replace('/[^0-9]/', '', $client['postcode']), - 'street' => str_replace(',', '', preg_replace('/[0-9]+/i', '', $client['address1'])), - 'number' => preg_replace('/[^0-9]/', '', $client['address1']), + 'street' => $street, + 'number' => $number, 'additionalInformation' => '', 'district' => $client['address2'], 'city' => [