" . getLngt("IMPORTDATEI:") . " " . $filename . "
";
// Customer and headquarters references have to exist
$hqId = "";
$csEid = "";
$objType = trim($objType);
$objId = trim($objId);
if ($objType == "CS" && is_numeric($objId)) :
// $csId = getFieldValueFromId("phoenix.customer", "cs_id", $objId, "cs_id");
$csId = $objId;
endif;
// Get $csId (if empty) from EID out of the filename
if ($csId == "") :
$posLastSlash = strripos($filename, "_");
$posLastSlash++;
$csEid = trim(substr($filename, $posLastSlash));
$csId = getFieldValueFromId("phoenix.customer", "cs_id", $csEid, "cs_eid");
if (is_numeric($csId)) :
$objId = $csId;
$objType = "CS";
endif;
endif;
// Get headquarters and EID
if ($csId != "") :
$hqId = getFieldValueFromId("phoenix.customer", "cs_id", $csId, "hq_id");
$csEid = getFieldValueFromId("phoenix.customer", "cs_id", $csId, "cs_eid");
endif;
if ($debug) :
echo "f_act : " . $f_act . "
";
echo "objType : " . $objType . "
";
echo "objId : " . $objId . "
";
echo "hqId : " . $hqId . "
";
echo "csId : " . $csId . "
";
echo "
";
endif;
if ($importFile != "") :
if ($hqId != "" && $csId != "") :
// Create internal representation
$srvpArray = array();
$zoneArray = array();
if (file_exists($importFile)) :
$currentTime = getDateTime("0");
// ********************
// * IMPORT FILE zone *
// ********************
if (!(strpos($filename, "import_RADIUSZONE_") === false)) :
$rowToImport = array();
$rowToImport[0] = "f_zone_no";
$rowToImport[1] = "f_zipcode";
$rowToImport[2] = "f_district";
$rowToImport[3] = "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_country = "DE";
$f_zone_no = removeFieldSigns($f_zone_no);
$f_zipcode = removeFieldSigns($f_zipcode);
$f_district = removeFieldSigns($f_district);
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($srvpId, $f_zipcode, $f_zone_no, $f_country, $f_district);
$x = array_search($f_zone_no, $zoneArray);
if ($x === FALSE) :
$zoneArray[] = $f_zone_no;
endif;
else :
$outText .= getLngt("PLZ " . $f_zipcode . " wird im Basisdatenbestand nicht geführt!") . "
";
endif;
else :
$outText .= getLngt("Keine PLZ im Datensatz!") . "
";
endif;
}
if ($debug) :
// print_r($zoneArray); echo "
";
// print_r($srvpArray); echo "
";
endif;
// Insert new zone zipcodes into the database from internal structure
if ($fire && $executeImportProcess == "1") :
$zoneArrayLen = count($zoneArray);
$srvpArrayLen = count($srvpArray);
TA("B");
// Delete zipcodes of the customer (and headquarters) and the specified zone
for ($k = 0; $k < $zoneArrayLen; $k++) :
deleteStmt("phoenix.serviceradius","srvz_id = '" . $zoneArray[$k] . "' AND cs_id = '" . $csId . "' AND hq_id = '" . $hqId . "'");
$outText .= getLngt("Zone " . $zoneArray[$k] . " für den Kunden " . $csEid . " wurde im Basisdatenbestand entfernt!") . "
";
endfor;
// Import new zipcodes
$executionCount = 0;
$existingCount = 0;
for ($k = 0; $k < $srvpArrayLen; $k++) :
// Check for existence of mapping entry
if (!existsEntry("phoenix.serviceradius",array("cs_id", $csId, "hq_id", $hqId, "srvr_zipcode", $srvpArray[$k][1], "srvr_zipcode", $srvpArray[$k][4]))) :
insertStmt("phoenix.serviceradius", array("cs_id", $csId, "hq_id", $hqId, "srvr_zipcode", $srvpArray[$k][1], "srvr_zipcode", $srvpArray[$k][4], "srvr_radiusarea_no", $srvpArray[$k][2])));
$executionCount++;
else :
$existingCount++;
endif;
endfor;
TA("C");
TA("E");
$outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "
");
$outText .= getLngt("Eingefügte Einträge: " . $executionCount . "
");
$outText .= getLngt("Existierende Einträge: " . $existingCount . "
");
// $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;
/*
CREATE TABLE servicezone (
srvz_id int(10) NOT NULL auto_increment,
hq_id int(10) NOT NULL default '0',
cs_id int(10) NOT NULL default '0',
srvz_no tinyint(3) default '0',
srvz_name varchar(50) NOT NULL default '',
srvz_price float(10,4) NOT NULL default '0.0000',
srvz_price2 float(10,4) NOT NULL default '0.0000',
PRIMARY KEY (srvz_id)
) ENGINE=InnoDB;
CREATE TABLE servicezonemapping (
srvz_id int(10) NOT NULL default '0',
srvp_id int(10) NOT NULL default '0'
) ENGINE=InnoDB;
*/
?>