"; echo "Feldname => Bedeutung
"; foreach($shiptos as $key=>$val) { echo "$key => $val
"; } exit(0); }; clearstatcache (); $trenner=($_POST["trenner"])?$_POST["trenner"]:","; if (!empty($_FILES["Datei"]["name"])) { $file=$_POST["ziel"]; if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file."_shipto.csv")) { $file=false; echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
"; } } else if (is_file($_POST["ziel"]."_shipto.csv")) { $file=$_POST["ziel"]; } else { $file=false; } if (!$file) ende (2); if (!file_exists($file."_shipto.csv")) ende(5); if (!file_exists("../users/$login.conf")) ende(3); $employee=chkUsr($login); if (!$employee) ende(4); if (!$db->chkcol($file)) ende(6); $f=fopen($file."_shipto.csv","r"); $zeile=fgets($f,1000); $infld=split($trenner,strtolower($zeile)); $first=true; foreach ($infld as $fld) { $fld = trim(strtr($fld,array("\""=>"","'"=>""))); $in_fld[]=$fld; } $j=0; $zeile=fgetcsv($f,1000,$trenner); while (!feof($f)){ $i=-1; $firma=""; $name=false; $id=false; $sql="insert into shipto "; $keys="("; $vals=" values ("; foreach($zeile as $data) { $i++; if ($in_fld[$i]=="firma") { $firma=addslashes(trim($data)); continue; }; if (!in_array($in_fld[$i],$shipto_fld)) { continue; } $data=addslashes(trim($data)); if ($in_fld[$i]=="trans_id" && $data) { $data=chkKdId($data); if ($data) $firma=""; if (!$id) $id = $data; continue; } if ($in_fld[$i]==$file."number" && $data) { $tmp=getFirma($data,$file); if ($tmp) $firma=""; if ($id<>$tmp) $id=$tmp; continue; } $keys.=$in_fld[$i].","; 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="0".$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) { // $zeile=fgetcsv($f,1000,$trenner); // continue; // } if ($firma) { $data=suchFirma($file,$firma); if ($data) { $vals.=$data["trans_id"].","; $keys.="trans_id,"; } } else if ($id) { $vals.=$id.","; $keys.="trans_id,"; } if ($keys<>"(") { if ($test) { if ($first) { echo "\n"; echo "\n"; $first=false; }; $vals=str_replace("',","'\n"; flush(); } else { $sql.=substr($keys,0,-1).")"; $sql.=substr($vals,0,-1).")"; $rc=$db->query($sql); if (!$rc) echo "Fehler: ".$sql."\n"; } $j++; }; $zeile=fgetcsv($f,1000,$trenner); } fclose($f); echo $j." $file importiert.\n";} else { ?>

Lieferanschriftimport für die ERP

".str_replace(",","",substr($keys,1,-1))."
",substr($vals,9,-1)); echo "
".str_replace("null,","null",$vals)."
Zieltabellecustomer vendor
Trennzeichen
Testja
Daten