From c25cb4622b88c268878dc814d4b8487584315fe7 Mon Sep 17 00:00:00 2001 From: Holger Lindemann Date: Wed, 13 Dec 2006 09:57:47 +0000 Subject: [PATCH] =?utf8?q?CSV-Importscripte=20f=C3=BCr=20Adressen,=20Konta?= =?utf8?q?kte,=20Lieferanschriften?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lxo-import/addressB.php | 205 +++++++++++++++++++++ lxo-import/contactB.php | 187 +++++++++++++++++++ lxo-import/import_lib.php | 371 ++++++++++++++++++++++++++++++++++++++ lxo-import/shiptoB.php | 184 +++++++++++++++++++ 4 files changed, 947 insertions(+) create mode 100644 lxo-import/addressB.php create mode 100644 lxo-import/contactB.php create mode 100644 lxo-import/import_lib.php create mode 100644 lxo-import/shiptoB.php diff --git a/lxo-import/addressB.php b/lxo-import/addressB.php new file mode 100644 index 000000000..5e19f7b4e --- /dev/null +++ b/lxo-import/addressB.php @@ -0,0 +1,205 @@ + + + +"; + echo "Fehlende oder falsche Daten."; + exit(1); +} + +if ($_POST["ok"]=="Hilfe") { + echo "Importfelder:
"; + echo "Feldname => Bedeutung
"; + foreach($address as $key=>$val) { + echo "$key => $val
"; + } + exit(0); +}; +clearstatcache (); +//print_r($_FILES); +$test=$_POST["test"]; +if (!empty($_FILES["Datei"]["name"])) { + $file=$_POST["ziel"]; + if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file.".csv")) { + $file=false; + echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
"; + } +} else if (is_file($_POST["ziel"].".csv")) { + $file=$_POST["ziel"]; +} else { + $file=false; +} + +if (!$file) ende (2); + +$trenner=($_POST["trenner"])?$_POST["trenner"]:","; +//echo "../users/$login.conf"; +if (!file_exists("../users/$login.conf")) ende(3); + +if (!file_exists("$file.csv")) ende(5); + +$db=new myDB($login); + +if (!$db->chkcol($file)) ende(6); + +$employee=chkUsr($login); +if (!$employee) ende(4); + +$kunde_fld = array_keys($address); + +$f=fopen("$file.csv","r"); +$zeile=fgets($f,1200); +$infld=split($trenner,strtolower($zeile)); +//echo "$zeile
"; +//print_r($infld); echo "
"; +$first=true; +$ok=true; +foreach ($infld as $fld) { + $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); + if ($fld=="branche" && !$crm) { $in_fld[]=""; continue; }; + if ($fld=="sw" && !$crm) { $in_fld[]=""; continue; }; + $in_fld[]=$fld; +} +//print_r($in_fld); echo "
"; +$j=0; +$m=0; +$zeile=fgetcsv($f,1200,$trenner); +if ($ok) while (!feof($f)){ + $i=0; + //echo "Arbeite an $m "; + $m++; + $anrede=""; + $Matchcode=""; + $sql="insert into $file "; + $keys="("; + $vals=" values ("; + $number=false; + foreach($zeile as $data) { + if (!in_array(trim($in_fld[$i]),$kunde_fld)) { + if ($in_fld[$i]=="anrede") { $anrede=addslashes(trim($data)); } + $i++; + continue; + }; + $data=trim($data); + //$data=htmlentities($data); + $data=addslashes($data); + if (trim($in_fld[$i])==$file."number") { // customernumber || vendornumber + if (empty($data) or !$data) { + $data=getKdId(); + $number=true; + } else { + $data=chkKdId($data); + $number=true; + } + } else if ($in_fld[$i]=="taxincluded"){ + $data=strtolower(substr($data,0,1)); + if ($data!="f" && $data!="t") $data="f"; + } else if ($in_fld[$i]=="language") { + $data=strtolower(substr($data,0,2)); + if (!in_array($data,array("de","en","fr"))) $data=false; + } + if ($in_fld[$i]=="matchcode") { + $matchcode=$data; + $i++; + continue; + } + + if ($data==false or empty($data) or !$data) { + if (in_array($in_fld[$i],array("name"))) { + $data=$matchcode; + } + } + $keys.=$in_fld[$i].","; + if ($data==false or empty($data) or !$data) { + if (in_array($in_fld[$i],array("name"))) { + $keys="("; + break; + } + $vals.="null,"; + } else { + if ($in_fld[$i]=="contact"){ + if ($anrede) { + $vals.="'$anrede $data',"; + } else { + $vals.="'$data',"; + } + } else { + $vals.="'".$data."',"; + } + } + $i++; + } + if (!$number) { + $keys.=$file."number,"; + $vals.="'".getKdId()."',"; + } + if ($keys<>"(") { + if ($test) { + if ($first) { + echo "\n"; + echo "\n"; + $first=false; + }; + $vals=str_replace("',","'\n"; + //echo "Import $j
\n"; + flush(); + } else { + $sql.=$keys."import)"; + $sql.=$vals."$nun)"; + $rc=$db->query($sql); + if (!$rc) echo "Fehler: ".$vals."
"; + } + $j++; + } else { + $vals=str_replace("',","'\n"; + flush(); + } + $zeile=fgetcsv($f,1200,$trenner); +} +fclose($f); +if ($test) echo "
".str_replace(",","",substr($keys,1,-1))."
",substr($vals,9,-1)); + echo "
".str_replace("null,","null",$vals)."
",substr($vals,9,-1)); + echo "
".str_replace("null,","null",$vals)."
\n ##### = Neue Kunden-/Lieferantennummer\n
"; +echo $j." $file importiert.\n"; +} else { +?> + +

Adressimport für die ERP

+
+

+ + + + + + + + + +
Zieltabellecustomer vendor
Trennzeichen
Testja
Daten
+
+ diff --git a/lxo-import/contactB.php b/lxo-import/contactB.php new file mode 100644 index 000000000..8c8e53a78 --- /dev/null +++ b/lxo-import/contactB.php @@ -0,0 +1,187 @@ + + + +"; + echo "Feldname => Bedeutung
"; + foreach($contact 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."_contact.csv")) { + $file=false; + echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
"; + } +} else if (is_file($_POST["ziel"]."_contact.csv")) { + $file=$_POST["ziel"]; +} else { + $file=false; +} + +if (!$file) ende (2); + +if (!file_exists($file."_contact.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."_contact.csv","r"); +$zeile=fgets($f,1200); +$infld=split($trenner,strtolower($zeile)); +$first=true; + + +foreach ($infld as $fld) { + $fld = trim(strtr($fld,array("\""=>"","'"=>""))); + $in_fld[]=$fld; +} +$j=0; +$zeile=fgetcsv($f,1200,$trenner); +while (!feof($f)){ + $i=-1; + $firma=""; + $name=false; + $id=false; + $sql="insert into contacts "; + $keys="("; + $vals=" values ("; + foreach($zeile as $data) { + $i++; + if ($in_fld[$i]=="firma") { + $firma=addslashes(trim($data)); + continue; + }; + if (!in_array($in_fld[$i],$kunde_fld)) { + continue; + } + $data=addslashes(trim($data)); + if ($in_fld[$i]=="cp_cv_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,1200,$trenner); + continue; + } + if ($firma) { + $data=suchFirma($file,$firma); + if ($data) { + $vals.=$data["cp_cv_id"].","; + $keys.="cp_cv_id,"; + } + } else if ($id) { + $vals.=$id.","; + $keys.="cp_cv_id,"; + } + if ($keys<>"(" && $val_count>2) { + 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,1200,$trenner); +} +fclose($f); +echo $j." $file importiert.\n";} else { +?> +

Kontakt-Adressimport 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
+ + diff --git a/lxo-import/import_lib.php b/lxo-import/import_lib.php new file mode 100644 index 000000000..89ca76f20 --- /dev/null +++ b/lxo-import/import_lib.php @@ -0,0 +1,371 @@ + "Firmenname", + "department_1" => "Abteilung", + "department_2" => "Abteilung", + "street" => "Strasse + Nr", + "zipcode" => "Plz", + "city" => "Ort", + "country" => "Land", + "contact" => "Ansprechpartner", + "phone" => "Telefon", + "fax" => "Fax", + "homepage" => "Homepage", + "email" => "eMail", + "notes" => "Bemerkungen", + "discount" => "Rabatt (nn.nn)", + "taxincluded" => "incl. Steuer? (t/f)", + "terms" => "Zahlungsziel (Tage)", + "customernumber" => "Kundennummer", + "vendornumber" => "Lieferantennummer", + "taxnumber" => "Steuernummer", + "account_number" => "Kontonummer", + "bank_code" => "Bankleitzahl", + "bank" => "Bankname", + "branche" => "Branche", + "language" => "Sprache (de,en,fr)", + "sw" => "Stichwort", + "creditlimit" => "Kreditlimit (nnnnnn.nn)", + "hierarchie" => "Hierarchie", + "potenzial" => "Potenzial", + "ar" => "Debitorenkonto", + "ap" => "Kreditorenkonto", + "matchcode" => "Matchcode", + "customernumber2" => "Kundennummer 2"); + +$shiptos = array( + "shiptoname" => "Firmenname", + "shiptodepartment_1" => "Abteilung", + "shiptodepartment_2" => "Abteilung", + "shiptostreet" => "Strasse + Nr", + "shiptozipcode" => "Plz", + "shiptocity" => "Ort", + "shiptocountry" => "Land", + "shiptocontact" => "Ansprechpartner", + "shiptophone" => "Telefon", + "shiptofax" => "Fax", + "shiptoemail" => "eMail", + "customernumber" => "Kundennummer", + "vendornumber" => "Lieferantennummer"); + +$parts = array( + "partnumber" => "Artikelnummer", + "description" => "Artikeltext", + "unit" => "Einheit", + "weight" => "Gewicht (kg)", + "onhand" => "Lagerbestand", + "notes" => "Beschreibung", + "makemodel" => "Hersteller", + "model" => "Modellbezeichnung", + "income_accno_id" => "Erlöskonto", + "expense_accno_id" => "Konto Umsatzkosten", + "bin" => "Lagerort", + "image" => "Pfad/Dateiname", + "drawing" => "Pfad/Dateiname", + "microfiche" => "Pfad/Dateiname", + "partsgroup_id" => "Name Warengruppe", + "listprice" => "Listenpreis", + "sellprice" => "Verkaufspreis", + "lastcost" => "letzter EK", + "art" => "Ware/Dienstleistung (*/d)"); + +$contactscrm = array( + "customernumber" => "Kundennummer", + "vendornumber" => "Lieferantennummer", + "cp_cv_id" => "FirmenID in der db", + "firma" => "Firmenname", + "cp_greeting" => "Anrede", + "cp_title" => "Titel", + "cp_givenname" => "Vorname", + "cp_greeting" => "Anrede", + "cp_name" => "Nachname", + "cp_email" => "eMail", + "cp_phone1" => "Telefon 1", + "cp_phone2" => "Telefon 2", + "cp_street" => "Strasse", + "cp_zipcode" => "PLZ", + "cp_city" => "Ort", + "cp_notes" => "Bemerkungen", + "cp_country" => "Land", + "cp_stichwort1" => "Stichwort(e)", + "katalog" => "Katalog", + "inhaber" => "Inhaber", + "contact_id" => "Kontakt ID" + ); + +$contacts = array( + "customernumber" => "Kundennummer", + "vendornumber" => "Lieferantennummer", + "cp_cv_id" => "FirmenID in der db", + "firma" => "Firmenname", + "cp_greeting" => "Anrede", + "cp_title" => "Titel", + "cp_givenname" => "Vorname", + "cp_greeting" => "Anrede", + "cp_name" => "Nachname", + "cp_email" => "eMail", + "cp_phone1" => "Telefon 1", + "cp_phone2" => "Telefon 2", + "katalog" => "Katalog", + "inhaber" => "Inhaber", + "contact_id" => "Kontakt ID" + ); + +function checkCRM() { +global $db; + $sql="select * from crm"; + $rs=$db->getAll($sql); + if ($rs) { + return true; + } else { + return false; + } +} + +function chkUsr($usr) { +// ist es ein gültiger ERP-Benutzer? Er muß mindestens 1 x angemeldet gewesen sein. +global $db; + $sql="select * from employee where login = '$usr'"; + $rs=$db->getAll($sql); + if ($rs[0]["id"]) { return $rs[0]["id"]; } + else { return false; }; +} + +function getKdId() { +// die nächste freie Kunden-/Lieferantennummer holen +global $db,$file,$test; + if ($test) { return "#####"; } + $sql1="select * from defaults"; + $sql2="update defaults set ".$file."number = '%s'"; + $db->lock(); + $rs=$db->getAll($sql1); + $nr=$rs[0][$file."number"]; + preg_match("/^([^0-9]*)([0-9]+)/",$nr,$hits); + if ($hits[2]) { $nr=$hits[2]+1; $nnr=$hits[1].$nr; } + else { $nr=$hits[1]+1; $nnr=$nr; }; + $rc=$db->query(sprintf($sql2,$nnr)); + if ($rc) { + $db->commit(); + return $nnr; + } else { + $db->rollback(); + return false; + }; +} + +function chkKdId($data) { +// gibt es die Nummer schon? +global $db,$file,$test; + $sql="select * from $file where ".$file."number = '$data'"; + $rs=$db->getAll($sql); + if ($rs[0][$file."number"]==$data) { + // ja, eine neue holen + return getKdId(); + } else { + return $data; + } +} + +function getKdRefId($data) { +// gibt es die Nummer schon? +global $db,$file,$test; + if (empty($data) or !$data) { + return false; + } + $sql="select * from $file where ".$file."number = '$data'"; + $rs=$db->getAll($sql); + return $rs[0]["id"]; +} + +function suchFirma($tab,$data) { +// gibt die Firma ? +global $db; + if (empty($data) or !$data) { + return false; + } + $data=strtoupper($data); + $sql="select * from $tab where upper(name) like '%$data%'"; + $rs=$db->getAll($sql); + if (!$rs) { + $org=$data; + while(strpos($data," ")>0) { + $data=ereg_replace(" "," ",$data); + } + $data=preg_replace("/[^A-Z0-9]/ ",".*",trim($data)); + $sql="select * from $tab where upper(name) ~ '$data'"; + $rs=$db->getAll($sql); + if (count($rs)==1) { + return array("cp_cv_id"=>$rs[0]["id"],"Firma"=>$rs[0]["name"]); + } + return false; + } else { + return array("cp_cv_id"=>$rs[0]["id"],"Firma"=>$rs[0]["name"]); + } +} + +$land=array("DEUTSC"=>"D","FRANKR"=>"F","SPANIE"=>"ES","ITALIE"=>"I","HOLLAN"=>"NL","NIEDER"=>"NL", + "BELGIE"=>"B","LUXEMB"=>"L","NORWEG"=>"N","FINNLA"=>"","GRIECH"=>"GR","OESTER"=>"A", + "SCHWEI"=>"CH","SCHWED"=>"S","AUSTRI"=>"A"); + +function mkland($data) { +global $land; + $data=strtr($data,array("Ö"=>"OE","Ä"=>"AE","Ü"=>"UE","ö"=>"OE","ä"=>"AE","ü"=>"UE","ß"=>"SS")); + $data=strtoupper(substr($data,0,6)); + $cntr=$land[$data]; + return (strlen($cntr)>0)?$cntr:substr($data,0,3); +} + +//Suche Nach Kunden-/Lieferantenummer +function getFirma($nummer,$tabelle) { +global $db; + $nummer=strtoupper($nummer); + $sql="select id from $tabelle where upper(".$tabelle."number) = '$nummer'"; + $rs=$db->getAll($sql); + if (!$rs) { + $nr=ereg_replace(" ","%",$nummer); + $sql="select id,".$tabelle."number from $tabelle where upper(".$tabelle."number) like '$nr'"; + $rs=$db->getAll($sql); + if ($rs) { + $nr=ereg_replace(" ","",$nummer); + foreach ($rs as $row) { + $tmp=ereg_replace(" ","",$row[$tabelle."number"]); + if ($tmp==$nr) return $row["id"]; + } + } else { + return false; + } + } else { + return $rs[0]["id"]; + } +} + +class myDB extends DB { +// Datenbankklasse + + var $rc = false; + var $showErr = false; + var $db = false; + var $debug = false; + +/**************************************************** +* uudecode +* in: string +* out: string +* dekodiert Perl-UU-kodierte Passwort-Strings +* http://de3.php.net/base64_decode (bug #171) +*****************************************************/ + function uudecode($encode) { + $b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + $encode = preg_replace("/^./m","",$encode); + $encode = preg_replace("/\n/m","",$encode); + for($i=0; $ishowErr) + echo "$sql : $err\n"; + } + + function showDebug($sql) { + echo $sql."\n"; + if ($this->debug==2) { + print_r($this->rc); + }; + } + + function myDB($usr) { + // Datenbankparameter des ERP-Users benutzen. + $tmp = file_get_contents("../users/$usr.conf"); + preg_match("/dbname => '(.+)'/",$tmp,$hits); + $dbname=$hits[1]; + preg_match("/dbpasswd => '(.+)'/",$tmp,$hits); + if ($hits[1]) { + $dbpasswd=$this->uudecode($hits[1]); + } else { + $dbpasswd=""; + }; + preg_match("/dbuser => '(.+)'/",$tmp,$hits); + $dbuser=$hits[1]; + preg_match("/dbhost => '(.+)'/",$tmp,$hits); + $dbhost=$hits[1]; + if (!$dbhost) $dbhost="localhost"; + if ($dbpasswd) { + $dns=$dbuser.":".$dbpasswd."@".$dbhost."/".$dbname; + } else { + $dns=$dbuser."@".$dbhost."/".$dbname; + }; + $dns="pgsql://".$dns; + $this->db=DB::connect($dns); + if (!$this->db) DB::dbFehler("oh oh oh",$this->db->getDebugInfo()); + if (DB::isError($this->db)) { + $this->dbFehler("Connect",$this->db->getDebugInfo()); + die ($this->db->getDebugInfo()); + } + return $this->db; + } + + function query($sql) { + $this->rc=@$this->db->query($sql); + if ($this->debug) $this->showDebug($sql); + if(DB::isError($this->rc)) { + $this->dbFehler($sql,$this->rc->getMessage()); + return false; + } else { + return $this->rc; + } + } + function getAll($sql) { + $this->rc=@$this->db->getAll($sql,DB_FETCHMODE_ASSOC); + if ($this->debug) $this->showDebug($sql); + if(DB::isError($this->rc)) { + $this->dbFehler($sql,$this->rc->getMessage()); + return false; + } else { + return $this->rc; + } + } + + function lock() { + $this->query("BEGIN"); + } + function commit() { + $this->query("COMMIT"); + } + function rollback() { + $this->query("ROLLBACK"); + } + function chkcol($tbl) { + // gibt es die Spalte import schon? + $rc=$this->db->query("select import from $tbl limit 1"); + if(DB::isError($rc)) { + $rc=$this->db->query("alter table $tbl add column import int4"); + if(DB::isError($rc)) { return false; } + else { return true; } + + } else { return true; }; + } +} + +?> diff --git a/lxo-import/shiptoB.php b/lxo-import/shiptoB.php new file mode 100644 index 000000000..946b17296 --- /dev/null +++ b/lxo-import/shiptoB.php @@ -0,0 +1,184 @@ + + + +"; + echo "Feldname => Bedeutung
"; + foreach($contact 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
+ + -- 2.20.1