X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=lxo-import%2FcontactB.php;h=5dd8891e55b525cc3e713b6fca64983bf210b398;hb=787407637f18ec17eab3fc8f31f3a4b56c9440a6;hp=e07bedb2ac0db405b21bc8ce3c14f34f5df27085;hpb=9dda820f45ce31c9c42902d61949d7679d2de94a;p=kivitendo-erp.git
diff --git a/lxo-import/contactB.php b/lxo-import/contactB.php
index e07bedb2a..5dd8891e5 100644
--- a/lxo-import/contactB.php
+++ b/lxo-import/contactB.php
@@ -1,7 +1,7 @@
-
+1) $trenner=chr(substr($trenner,1));
+ }
+
if (!empty($_FILES["Datei"]["name"])) {
$file=$_POST["ziel"];
- if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file."_contact.csv")) {
+ if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file."_contact.csv")) {
$file=false;
echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
";
}
-} else if (is_file($_POST["ziel"]."_contact.csv")) {
+} else if (is_file($dir.$_POST["ziel"]."_contact.csv")) {
$file=$_POST["ziel"];
} else {
$file=false;
@@ -70,16 +77,49 @@ if (!empty($_FILES["Datei"]["name"])) {
if (!$file) ende (2);
-if (!file_exists($file."_contact.csv")) ende(5);
+if (!file_exists($dir.$file."_contact.csv")) ende(5);
-$prenumber=$_POST["prenumber"];
+//$prenumber=$_POST["prenumber"];
$employee=chkUsr($_SESSION["employee"]);
if (!$employee) ende(4);
if (!$db->chkcol($file)) ende(6);
-$f=fopen($file."_contact.csv","r");
+ //Zeichencodierung des Servers
+ $tmpcode = $db->getServerCode();
+ //Leider sind die Benennungen vom Server anders als von mb_detect_encoding
+ if ($tmpcode == "UTF8") {
+ define("ServerCode","UTF-8");
+ } else if ($tmpcode == "LATIN9") {
+ define("ServerCode","ISO-8859-15");
+ } else if ($tmpcode == "LATIN1") {
+ define("ServerCode","ISO-8859-1");
+ } else {
+ define("ServerCode",$tmpcode);
+ }
+ //Zeichensatz sollte gleich sein, sonst ist die Datenkonvertierung nutzlos
+ //DB und LxO müssen ja nicht auf der gleichen Maschiene sein.
+ if($tmpcode<>$db->getClientCode()) {
+ $rc = $db->setClientCode($tmpcode);
+ }
+
+ // Zeichenkodierung File
+ if ($_POST["encoding"] == "auto") {
+ define("Auto",true);
+ define("Translate",true);
+ } else {
+ define("Auto",false);
+ if ($_POST["encoding"] == ServerCode) {
+ define("Translate",false);
+ } else {
+ define("Translate",true);
+ define("FileCode",$_POST["encoding"]);
+ }
+ }
+
+
+$f=fopen($dir.$file."_contact.csv","r");
$zeile=fgetcsv($f,2000,$trenner);
$first=true;
@@ -87,6 +127,7 @@ $first=true;
foreach ($zeile as $fld) {
$fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
$in_fld[]=$fld;
+ if (substr($fld,0,2) == "x_") $kunde_fld[] = $fld;
}
$j=0;
$zeile=fgetcsv($f,2000,$trenner);
@@ -98,6 +139,8 @@ while (!feof($f)){
$sql="insert into contacts ";
$keys="(";
$vals=" values (";
+ unset($extra);
+ $extra = array();
foreach($zeile as $data) {
$i++;
if (!in_array($in_fld[$i],$kunde_fld)) {
@@ -105,6 +148,7 @@ while (!feof($f)){
}
$data=addslashes(trim($data));
if ($in_fld[$i]=="firma" && $data) {
+ if (Translate) translate($data);
$data=suchFirma($file,$data);
if ($data) {
$id=$data["cp_cv_id"];
@@ -122,6 +166,12 @@ while (!feof($f)){
} else if($in_fld[$i]=="cp_cv_id") {
continue;
}
+ if (substr($in_fld[$i],0,2)=="x_" && $data) {
+ $extra[substr($in_fld[$i],2)] = $data;
+ continue;
+ } else if ((substr($in_fld[$i],0,2)=="x_")) {
+ continue;
+ };
if ($in_fld[$i]==$file."number" && $data) {
if (!$id) {
$tmp=getFirma($data,$file);
@@ -149,15 +199,18 @@ while (!feof($f)){
if ($data==false or empty($data) or !$data) {
$vals.="null,";
} else {
- if (in_array($in_fld[$i],array("cp_fax","cp_phone1","cp_phone2"))) {
- $data=$prenumber.$data;
- } else if ($in_fld[$i]=="cp_country" && $data) {
- $data=mkland($data);
- }
- if ($in_fld[$i]=="cp_name") $name=true;
- $vals.="'".$data."',";
- // bei jedem gefuellten Datenfeld erhoehen
- $val_count++;
+
+ if (Translate) translate($data);
+
+ /*if (in_array($in_fld[$i],array("cp_fax","cp_phone1","cp_phone2"))) {
+ $data=$prenumber.$data;
+ } else if ($in_fld[$i]=="cp_country" && $data) {
+ $data=mkland($data);
+ } */
+ if ($in_fld[$i]=="cp_name") $name=true;
+ $vals.="'".$data."',";
+ // bei jedem gefuellten Datenfeld erhoehen
+ $val_count++;
}
}
if (!$name) {
@@ -179,10 +232,20 @@ while (!feof($f)){
echo "".str_replace("null,","null | ",$vals)." |
\n";
flush();
} else {
- $sql.=substr($keys,0,-1).")";
- $sql.=substr($vals,0,-1).")";
+ $newID=uniqid (rand());
+ $now = date('Y-m-d H:i').":1.$j";
+ $sql.= $keys."mtime)";
+ $sql.= $vals."'$now')";
$rc=$db->query($sql);
if (!$rc) echo "Fehler: ".$sql."\n";
+ $rs = $db->getAll("select cp_id,cp_name from contacts where mtime = '$now'");
+ $cp_id = $rs[0]["cp_id"];
+ echo "(".$rs[0]["cp_name"].":$cp_id)".count($extra).";";
+ if (count($extra)>0 and $cp_id) {
+ foreach ($extra as $fld=>$val) {
+ $rc = insertExtra("P",$cp_id,$fld,$val);
+ }
+ }
}
$j++;
};
@@ -193,15 +256,32 @@ echo $j." $file importiert.\n";} else {
?>
Kontakt-Adressimport für die ERP
- }; ?>
+