";
echo "objType : " . $objType . "
";
echo "objId : " . $objId . "
";
echo "hq_id : " . $hq_id . "
";
echo "csId : " . $csId . "
";
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 ($hq_id != "") :
if (file_exists($importFile)) :
$currentTime = getDateTime("0");
// ********************
// * IMPORT FILE zone *
// ********************
if (!(strpos($filename, "import_ZIPCODE_NEIGHBOURS_") === false)) :
/*
- CSV-Datei
- die 1. Spalte enthält die PLZ, für die die folgenden Nachbar-PLZn angelegt werden sollen (Spalte 2 bin Spalte n)
- Format-Beispiel:
80331;80539;80469;80538;80336;80335;80333;80337;;;;
80333;80539;80331;80335;80798;80799;80797;80336;;;;
80335;80333;80331;80336;80339;80636;80797;;;;;
80336;80331;80337;81373;80339;80335;80333;81371;80469;;;
80337;80469;81371;80336;80331;81373;81543;;;;;
80339;80336;81373;80686;80634;80636;80335;80639;80687;80337;;
80469;81541;81543;81371;80337;80538;81667;80331;80539;80336;;
80538;80802;81679;81675;81667;80469;80331;80539;81669;;;
80539;80538;80469;80331;80333;80799;80802;80801;;;;
80634;80636;80339;80639;80637;80335;80638;80687;;;;
*/
$rowToImport = array();
$rowToImport[0] = "f_zipcode";
$rowToImport[1] = "f_zip_01";
$rowToImport[2] = "f_zip_02";
$rowToImport[3] = "f_zip_03";
$rowToImport[4] = "f_zip_04";
$rowToImport[5] = "f_zip_05";
$rowToImport[6] = "f_zip_06";
$rowToImport[7] = "f_zip_07";
$rowToImport[8] = "f_zip_08";
$rowToImport[9] = "f_zip_09";
$rowToImport[10] = "f_zip_10";
$rowToImport[11] = "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];
}
$zipcodeArray = array(); // Init
$f_zipcode = removeFieldSigns($f_zipcode);
$zipcodeArray[0] = $f_zipcode;
$zipcodeArray[1] = removeFieldSigns($f_zip_01);
$zipcodeArray[2] = removeFieldSigns($f_zip_02);
$zipcodeArray[3] = removeFieldSigns($f_zip_03);
$zipcodeArray[4] = removeFieldSigns($f_zip_04);
$zipcodeArray[5] = removeFieldSigns($f_zip_05);
$zipcodeArray[6] = removeFieldSigns($f_zip_06);
$zipcodeArray[7] = removeFieldSigns($f_zip_07);
$zipcodeArray[8] = removeFieldSigns($f_zip_08);
$zipcodeArray[9] = removeFieldSigns($f_zip_09);
$zipcodeArray[10] = removeFieldSigns($f_zip_10);
$zipcodeArrayLen = count($zipcodeArray);
$outText .= "(" . $j . ".) ";
if ($f_zipcode != "") : // ">1", because $zipcodeArray[1] ist first neighbour
if ($zipcodeArrayLen > 1) : // ">1", because $zipcodeArray[1] ist first neighbour
// Get srvp_id from serviceplz
$srvpId = getFieldValueFromId("phoenix.serviceplz", "srvp_plz", $f_zipcode, "srvp_id");
if ($srvpId != "") :
$outText .= $f_zipcode . " => ";
for ($z = 1; $z < $zipcodeArrayLen; $z++) : // ($z = 1) <=> First neighbour
if ($zipcodeArray[$z] != "") :
$srvpIdNeighbour = getFieldValueFromId("phoenix.serviceplz", "srvp_plz", $zipcodeArray[$z], "srvp_id");
if ($srvpIdNeighbour != "") :
// Insert into serviceplzneighbour if does not exist
if ($executeImportProcess == "1") :
if (!existsEntry("phoenix.serviceplzneighbour",array("hq_id", $hq_id, "srvp_id", $srvpId, "srvp2_id", $srvpIdNeighbour))) :
if ($fire) :
insertStmt("phoenix.serviceplzneighbour", array("hq_id", $hq_id, "srvp_id", $srvpId, "srvp2_id", $srvpIdNeighbour, "srvpn_sort", $z));
$outText .= "[" . $zipcodeArray[$z] . " : INS_OK] ";
else :
$outText .= "[" . $zipcodeArray[$z] . " : INS_RDY2IMP] "; // Ready to be imported
endif;
else :
$outText .= "[" . $zipcodeArray[$z] . " : EXISTS] ";
endif;
else :
$outText .= "[" . $zipcodeArray[$z] . "] ";
endif;
else :
$outText .= "" . "[" . getLngt("NB-PLZ " . $zipcodeArray[$z] . " NIB!") . "] "; // Nachbar-PLZ nicht im Basisdatenbestand
endif;
else :
$outText .= "" . "[" . getLngt("NB-PLZ NA!") . "] "; // Nachbar-PLZ nicht in der Importdatei angegeben
endif;
endfor;
else :
$outText .= "[" . getLngt("Basis-PLZ " . $f_zipcode . " wird im Basisdatenbestand nicht geführt!") . "] ";
endif;
else :
$outText .= getLngt("Keine Nachbar-PLZ angegeben!") . "
";
endif;
else :
$outText .= getLngt("Basis-PLZ nicht angegeben!") . "
";
endif;
$outText .= "
";
}
endif;
/*
TA("B");
TA("C");
TA("E");
*/
else :
$statusMessage .= getLngt("Die angegebene Datei existiert nicht!");
endif;
else :
$statusMessage .= getLngt("Diese Datei muss für eine bestimmte Niederlassung verarbeitet werden!");
endif;
else :
$statusMessage .= getLngt("Es wurde keine Datei spezifiziert!");
endif;
?>