BMD Export update
This commit is contained in:
@@ -284,6 +284,7 @@ class AddressController extends mfBaseController {
|
||||
|
||||
}
|
||||
|
||||
$country_code_errors = [];
|
||||
$export_addresses = [];
|
||||
|
||||
foreach($addresses as $fibu_num => $address) {
|
||||
@@ -300,7 +301,28 @@ class AddressController extends mfBaseController {
|
||||
$a["street"] = $address->street;
|
||||
$a["zip"] = $address->zip;
|
||||
$a["city"] = $address->city;
|
||||
$a["countrycode"] = ($address->country) ? __($address->country, "cc") : "AT";
|
||||
if(strlen($address->country) == 2) {
|
||||
$a["countrycode"] = trim($address->country);
|
||||
} else {
|
||||
$a["countrycode"] = "AT";
|
||||
|
||||
if(trim($address->country)) {
|
||||
$acountry = strtolower(trim($address->country));
|
||||
$cc = __($acountry, "cc");
|
||||
|
||||
$this->log->debug("is $cc == cc.$acountry");
|
||||
$this->log->debug("last translation failed: ".(__last_translation_failed() ? "true" : "false"));
|
||||
|
||||
if(__last_translation_failed()) {
|
||||
//if($cc == "cc.".$acountry) {
|
||||
$a["countrycode"] = "AT";
|
||||
// email to buchhaltung
|
||||
$country_code_errors[$fibu_num] = $address;
|
||||
} else {
|
||||
$a["countrycode"] = $cc;
|
||||
}
|
||||
}
|
||||
}
|
||||
$a["phone"] = "";
|
||||
if($address->mobile) $a["phone"] = $address->mobile;
|
||||
if($address->phone) $a["phone"] = $address->phone;
|
||||
@@ -347,6 +369,19 @@ class AddressController extends mfBaseController {
|
||||
$export_addresses[] = $a;
|
||||
}
|
||||
|
||||
if(count($country_code_errors)) {
|
||||
$msg = "Hallo,\r\n\r\ndas in thetool eingetragene Land von folgenden Kunden/Lieferanten konnte nicht in einen ISO-Code übersetzt werden:\r\n\r\n";
|
||||
foreach($country_code_errors as $fibu_num => $address) {
|
||||
$msg .= "$fibu_num (".$address->getCompanyOrName()."): ".$address->country."\r\n";
|
||||
}
|
||||
|
||||
$email = new Emailnotification();
|
||||
$email->setFrom(TT_OUTGOING_EMAIL, "thetool");
|
||||
$email->setTo(TT_FIBU_EMAIL_TO);
|
||||
$email->setSubject("[BMD-Export] Fehlerhaftes Land");
|
||||
$email->setBody($msg);
|
||||
$email->send();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user