";
echo "objType : " . $objType . "
";
echo "objId : " . $objId . "
";
echo "hqId : " . $hqId . "
";
echo "csId : " . $csId . "
";
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 . "
";
// Check group names for accessing the script !!!!
$groupId = "";
$groupName = "";
$tmpPosForGrpName = strrpos($filename, "_");
if (!($tmpPosForGrpName === false)) :
$groupName = substr($filename, $tmpPosForGrpName + 1);
// Remove extension if does exist
$tmpPosForGrpName = strrpos($groupName, ".");
if (!($tmpPosForGrpName === false)) :
$groupName = substr($groupName, 0, $tmpPosForGrpName);
endif;
$groupId = getFieldValueFromId("phoenix.groups", "grp_name", $groupName, "grp_id");
endif;
if ($debug) :
echo "groupName : " . $groupName . "
";
echo "groupId : " . $groupId . "
";
echo "
";
endif;
if ($importFile != "" && (($csId != "" && $csId != "0") || $groupId != "")) :
if (file_exists($importFile)) :
$currentTime = getDateTime("0");
// ***********************
// * IMPORT FILE article *
// ***********************
if (!(strpos($filename, "import_ARTICLEGROUP_") === false)) :
$executionCount = 0;
$insertCount = 0;
$updateCount = 0;
$failedCount = 0;
$rowToImport = array();
$parImportArticleFieldsGroup == "";
if ($groupId != "") :
$parImportArticleFieldsGroup = getParameterValue("0", "IMPORT_ARTICLEGROUP_FIELDS_GROUP_" . $groupId, "0");
endif;
if ($parImportArticleFieldsGroup != "") :
/*
$parImportArticleFieldsGroupArray = spliti(",", $parImportArticleFieldsGroup);
$parImportArticleFieldsGroupArrayLen = count($parImportArticleFieldsGroupArray);
for ($k = 0; $k < $parImportArticleFieldsGroupArrayLen; $k++) :
$rowToImport[$k] = $parImportArticleFieldsGroupArray[$k];
endfor;
*/
$rowToImport = spliti(",", $parImportArticleFieldsGroup);
else :
// Default
$rowToImport[0] = "f_atg_key"; // Articlegroup key/no.
$rowToImport[1] = "f_atg_name"; // Articlegroup name
$rowToImport[2] = "f_atg_dummy";
endif;
$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_atg_key = removeFieldSigns($f_atg_key);
$f_atg_name = removeFieldSigns($f_atg_name);
$f_hq_id = "0";
if ($f_atg_key != "") :
// Insert new article
if ($fire && $executeImportProcess == "1") :
// TA("B");
$currAtgId = "";
if (existsEntry("articlegroup",array("atg_key",$f_atg_key))) :
// Update articlegroup
$res = updateStmt("phoenix.articlegroup", "atg_key", $f_atg_key, array("atg_name", $f_atg_name));
// Check update for success
if ($db->affected_rows > 0) :
$executionCount++;
$updateCount++;
$currAtgId = getFieldValueFromId("phoenix.articlegroup", "atg_key", $f_atg_key, "atg_id");
$outText .= getLngt("Update der Artikelgruppe:") . " " . $f_atg_key . " - " . $f_atg_name . "
";
else :
$failedCount++;
endif;
else :
// Insert article
if ($f_atg_name != "") :
insertStmt("phoenix.articlegroup", array("atg_key", $f_atg_key, "atg_name", $f_atg_name));
$currAtgId = getLastInsertId();
$executionCount++;
$insertCount++;
else :
$outText .= getLngt("Die Artikelgruppe hat zwar einen Schlüssel, aber keinen Namen:") . " " . $f_atg_key . "
";
$failedCount++;
endif;
endif;
// Update group information if a group has to be associated ($groupId != "") and the article does exist or has been inserted
if ($groupId != "" && $currAtgId != "" && is_numeric($currAtgId)) :
// Update group association
$groupsOfcurrArticle = getFieldValueFromId("phoenix.articlegroup", "atg_id", $currAtgId, "atg_group");
if ($groupsOfcurrArticle == "") :
$res = updateStmt("phoenix.articlegroup", "atg_id", $currAtgId, array("atg_group", "," . $groupId . ","));
elseif (strpos($groupsOfcurrArticle, "," . $groupId . ",") === false) :
$res = updateStmt("phoenix.articlegroup", "atg_id", $currAtgId, array("atg_group", $groupsOfcurrArticle . $groupId . ","));
endif;
endif;
// TA("C");
// TA("E");
// $closeWindow = "1";
endif;
else :
$outText .= getLngt("Keine Artikelgruppe im Datensatz!") . "
";
endif;
}
$outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "
");
$outText .= getLngt("Verarbeitete Einträge: " . $executionCount . "
");
$outText .= getLngt("Neue Einträge: " . $insertCount . "
");
$outText .= getLngt("Modifizierte Einträge: " . $updateCount . "
");
$outText .= getLngt("INSERT oder UPDATE final nicht durchgeführt: " . $failedCount . "
");
else :
$statusMessage .= getLngt("Die angegebene Datei scheint nicht kompatibel zur angeforderten Importfunktionalität!");
endif;
else :
$statusMessage .= getLngt("Die angegebene Datei existiert nicht!");
endif;
else :
$statusMessage .= getLngt("Es wurde keine Datei spezifiziert!");
endif;
?>