";
echo "objType : " . $objType . "
";
echo "objId : " . $objId . "
";
echo "hqId : " . $hqId . "
";
echo "csId : " . $csId . "
";
echo "srvzIdArray : " . implode(",", $srvzIdArray) . "
";
echo "
";
endif;
// Current file to be imported
$importFile = urldecode($importFile);
$posLastSlash = strripos($importFile, "/");
$posLastSlash++;
$pathname = substr($importFile, 0, $posLastSlash);
$filename = substr($importFile, $posLastSlash);
$outText = "" . getLngt("IMPORTDATEI:") . " " . $filename . "
";
if ($importFile != "") :
if ($hqId != "" && $csId != "" && $srvzIdArrayLen > 0) :
// Create internal representation
$srvpArray = array();
$srvzIdsOfCurrentCustomer = implode(",", $srvzIdArray); // Zone IDs of the current customer
if (file_exists($importFile)) :
$currentTime = getDateTime("0");
$executionCount = 0;
$failedCount = 0;
// ********************
// * IMPORT FILE zone *
// ********************
if (!(strpos($filename, "import_ZONEAGIO_") === false)) :
// PLZ
// 22844
// 22850
// ...
// 22xxx
// ...
$rowToImport = array();
$rowToImport[0] = "f_zipcode";
$rowToImport[1] = "f_price";
$rowToImport[2] = "f_dummy";
$rowToImportLen = count($rowToImport);
// read file to import
$data = importCSV($importFile, $delimiter);
$dataLen = count($data);
// loop all rows (EXCEPT header row [$j = 1])
for ($j = 0; $j < $dataLen; $j++) {
// loop for all fields of $fields of the row
for ($i = 0; $i < $rowToImportLen; $i++) {
${$rowToImport[$i]} = $data[$j][$i];
}
$f_zipcode = removeFieldSigns($f_zipcode);
$f_price = str_replace(",", ".", $f_price);
if ($f_price == "" || !is_numeric($f_price)) :
$f_price = "0.00";
endif;
$f_country = "";
if ($f_zipcode != "") :
if ($f_country == "" || !existsEntry("phoenix_special.country",array("cou_iso_2",$f_country))) :
$f_country = "DE";
endif;
// Get srvp_id from serviceplz
$srvpId = getFieldValueFromId("phoenix.serviceplz", "srvp_plz", $f_zipcode, "srvp_id");
if ($srvpId != "") :
// If country "Germany" then fill zipcode with "0" up to 5 chars
if ($f_country == "DE") :
$f_zipcode = pad($f_zipcode, 5);
endif;
// Set arrays
$srvpArray[] = array($f_zipcode, $srvpId, $f_country, $f_price);
else :
$outText .= getLngt("PLZ " . $f_zipcode . " wird im Basisdatenbestand nicht geführt!") . "
";
endif;
else :
$outText .= getLngt("Keine PLZ im Datensatz!") . "
";
endif;
}
// Insert new zone zipcodes into the database from internal structure
if ($fire && $executeImportProcess == "1") :
$srvpArrayLen = count($srvpArray);
TA("B");
// Remove ALL ZONEAGIO associations for the CURRENT CUSTOMER
updateStmt("phoenix.servicezonemapping", "", "", array("srvzm_mt_2", "0.00"), "srvz_id IN (" . $srvzIdsOfCurrentCustomer . ")");
// Associate zipcodes to be enabled for ZONEAGIO for the current customer
for ($k = 0; $k < $srvpArrayLen; $k++) :
$res = updateStmt("phoenix.servicezonemapping", "srvp_id", $srvpArray[$k][1], array("srvzm_mt_2", $srvpArray[$k][3]), "srvz_id IN (" . $srvzIdsOfCurrentCustomer . ")");
// Check update for success
if ($db->affected_rows > 0) :
$executionCount++;
$outText .= getLngt("Update PLZ:") . " " . $srvpArray[$k][0] . " " . getLngt("mit Preis") . " " . $srvpArray[$k][3] . "
";
else :
$failedCount++;
endif;
endfor;
TA("C");
TA("E");
$outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "
");
$outText .= getLngt("Verarbeitete Einträge: " . $executionCount . "
");
$outText .= getLngt("Nicht verarbeitete Einträge: " . $failedCount . "
");
// $closeWindow = "1";
endif;
endif;
// ********************
// * IMPORT FILE xxxx *
// ********************
// if (!(strpos($filename, "import_xxxx") === false)) :
// endif;
else :
$statusMessage .= getLngt("Die angegebene Datei existiert nicht!");
endif;
else :
$statusMessage .= getLngt("Diese Datei muss für einen bestimmten Kunden verarbeitet werden!");
endif;
else :
$statusMessage .= getLngt("Es wurde keine Datei spezifiziert!");
endif;
?>