From 1d69ac97a6ccc808e72e951495e4dfa728ca832e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 16 Jun 2011 09:36:52 +0200 Subject: [PATCH] PHP-basierten CSV-Import-Code entfernt --- lxo-import/addressB.php | 310 ------------------ lxo-import/blz.php | 162 ---------- lxo-import/contactB.php | 290 ----------------- lxo-import/customer.bsp | 2 - lxo-import/customer_contact.bsp | 2 - lxo-import/customer_shipto.bsp | 2 - lxo-import/db.php | 159 --------- lxo-import/import_lib.php | 444 -------------------------- lxo-import/parts.bsp | 4 - lxo-import/partsB.php | 243 -------------- lxo-import/parts_import.php | 550 -------------------------------- lxo-import/partshead.csv | 1 - lxo-import/shiptoB.php | 233 -------------- lxo-import/ups.html | 19 -- menu.ini | 18 -- 15 files changed, 2439 deletions(-) delete mode 100644 lxo-import/addressB.php delete mode 100644 lxo-import/blz.php delete mode 100644 lxo-import/contactB.php delete mode 100644 lxo-import/customer.bsp delete mode 100644 lxo-import/customer_contact.bsp delete mode 100644 lxo-import/customer_shipto.bsp delete mode 100644 lxo-import/db.php delete mode 100644 lxo-import/import_lib.php delete mode 100644 lxo-import/parts.bsp delete mode 100644 lxo-import/partsB.php delete mode 100644 lxo-import/parts_import.php delete mode 100644 lxo-import/partshead.csv delete mode 100644 lxo-import/shiptoB.php delete mode 100644 lxo-import/ups.html diff --git a/lxo-import/addressB.php b/lxo-import/addressB.php deleted file mode 100644 index 53d674643..000000000 --- a/lxo-import/addressB.php +++ /dev/null @@ -1,310 +0,0 @@ - - - -"; - exit(1); -} - -if (!$_SESSION["db"]) { - $conffile="../config/lx_office.conf"; - if (!is_file($conffile)) { - ende("lx_office.conf nicht gefunden oder unlesbar"); - } -} - -if (!anmelden()) ende("Anmeldung fehlgeschlagen"); - -if ($_POST["ok"]=="Hilfe") { - echo "Importfelder:
"; - echo "Feldname => Bedeutung
"; - foreach($address as $key=>$val) { - echo "$key => $val
"; - } - $header=implode(";",array_keys($address)); - echo $header; - exit(0); -}; - -if ($_POST["ok"]) { - -$nun=time(); - - -/* get DB instance */ -$db=$_SESSION["db"]; //new myDB($login); - -$crm=checkCRM(); - -$dir = "../users/"; -clearstatcache (); -//print_r($_FILES); -$test=$_POST["test"]; -if (!empty($_FILES["Datei"]["name"])) { - $file=$_POST["ziel"]; - if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv")) { - $file=false; - echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
"; - } -} else if (is_file($dir.$_POST["ziel"].".csv")) { - $file=$_POST["ziel"]; -} else { - $file=false; -} - -if (!$file) ende ("Kein Datenfile"); - -$trenner=($_POST["trenner"])?$_POST["trenner"]:","; -if ($trenner=="other") { - $trenner=trim($trennzeichen); -} -if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); - -if (!file_exists($dir.$file.".csv")) ende("$file.csv nicht im Ordner oder leer"); - -if (!$db->chkcol($file)) ende("Importspalte kann nicht angelegt werden"); - -$employee=chkUsr($_SESSION["employee"]); -if (!$employee) ende("Ungültiger User"); - -$kunde_fld = array_keys($address); - - //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"]); - } - } - -function chkBusiness($data,$id=true) { -global $db; - if ($id) { - $rs = $db->getAll("select id from business where id =$data"); - } else { - $rs = $db->getAll("select id from business where decription ilike '$data'"); - } - if ($rs[0]["id"]) { - return $rs[0]["id"]; - } else { - return "null"; - } -} - -function chkSalesman($data,$id=true) { -global $db; - if ($id) { - $rs = $db->getAll("select id from employee where id =$data"); - } else { - $rs = $db->getAll("select id from employee where login ilike '$data'"); - } - if ($rs[0]["id"]) { - return $rs[0]["id"]; - } else { - return "null"; - } -} - -$f=fopen($dir.$file.".csv","r"); -$zeile=fgets($f,1200); -$infld=explode($trenner,strtolower($zeile)); -$first=true; -$ok=true; -$p=0; -foreach ($infld as $fld) { - $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); - if (in_array($fld,$kunde_fld)) { - if ($fld=="branche" && !$crm) { continue; }; - if ($fld=="sw" && !$crm) { continue; }; - $in_fld[$fld]=$p; - //$fldpos[$fld]=$p; - //$in_fld[]=$fld; - } - $p++; -} -$infld = array_keys($in_fld); -$infld[] = "import"; -$infld = implode(",",$infld); -$j=0; -$m=0; -$zeile=fgetcsv($f,1200,$trenner); -if ($ok) while (!feof($f)){ - $i=0; - $m++; - $anrede=""; - $Matchcode=""; - $sql="insert into $file "; - $keys=array(); - $vals=array(); - $number=false; - //foreach($zeile as $data) { - - foreach($in_fld as $fld => $pos) { - switch ($fld) { - case "name" : - case "department_1" : - case "department_2" : - case "matchcode" : - case "street" : - case "city" : - case "notes" : - case "sw" : - case "branche" : - case "country" : - case "contact" : - case "homepage" : - case "email" : - case "bank" : $data = addslashes(trim($zeile[$pos])); - if (Translate) translate($data); - case "ustid" : $data = strtr(trim($zeile[$pos])," ",""); - case "bank_code" : $data = trim($zeile[$pos]); - case "account_number": - case "greeting" : - case "taxnumber" : - case "zipcode" : - case "phone" : - case "fax" : $data = trim($zeile[$pos]); - $data = "'$data'"; - if ($data=="''") { - $vals[] = "null"; - } else { - $vals[] = $data; - } - break; - case "business_id" : $vals[] = chkBusiness(trim($zeile[$pos])); - break; - case "salesman_id" : $vals[] = chkSalesman(trim($zeile[$pos])); - break; - case "taxincluded" : $data = strtolower(substr($zeile[$pos],0,1)); - if ($data!="f" && $data!="t") { $vals[] = "'f'"; } - else { $vals[] = "'".$data."'";} - break; - case "taxzone_id" : $data = trim($zeile[$pos])*1; - if ($data>3 && $data<0) $data = 0; - $vals[] = $data; - break; - case "creditlimit" : - case "discount" : - case "terms" : $vals[] = trim($zeile[$pos])*1; - break; - case "customernumber": - case "vendornumber" : $data = trim($zeile[$pos]); - if (empty($data) or !$data) { - $vals[] = getKdId(); - $number = true; - } else { - $vals[] = chkKdId($data); - $number = true; - } - break; - } - }; - if (!in_array("taxzone_id",$in_fld)) { - $in_fld[] = "taxzone_id"; - $vals[] = 0; - } - // seit 2.6 ist die DB-Kodierung UTF-8 @holger Ansonsten einmal vorher die DB-Encoding auslesen - // Falls die Daten ISO-kodiert kommen entsprechend wandeln - // done! - // UTF-8 MUSS als erstes stehen, da ansonsten die Prüfung bei ISO-8859-1 aufhört ... - // die blöde mb_detect... tut leider nicht immer, daher die Möglichkeit der Auswahl - // TODO Umlaute am Anfang wurden bei meinem Test nicht übernommen (Österreich). S.a.: - // http://forum.de.selfhtml.org/archiv/2007/1/t143904/ - if ($test) { - if ($first) { - echo "\n\n"; - $first=false; - }; - echo "\n"; - //echo "Import $j
\n"; - flush(); - } else { - $vals[] = $nun; - $sql = "INSERT INTO $file (".$infld.") values (".implode(",",$vals).")"; - $rc=$db->query($sql); - if ($j % 10 == 0) { echo "."; flush(); }; - if (!$rc) { echo "
Fehler: ".$sql."
"; flush(); }; - } - $j++; - $zeile=fgetcsv($f,1200,$trenner); -} -fclose($f); -if ($test) echo "
"; - echo implode('',array_keys($in_fld)); - echo "
"; - echo implode('',$vals); - echo "
\n ##### = Neue Kunden-/Lieferantennummer\n
"; -echo $j." $file importiert.\n"; -} else { -?> - -

Adressimport für die ERP

-
-

- - - - - - - - - - - -
Zieltabellecustomer vendor
Trennzeichen - Semikolon - Komma - Tabulator - Leerzeichen - - -
Testja
Daten
Verwendete
Zeichecodierung
- -
-
- diff --git a/lxo-import/blz.php b/lxo-import/blz.php deleted file mode 100644 index 482aa6bf8..000000000 --- a/lxo-import/blz.php +++ /dev/null @@ -1,162 +0,0 @@ - - - - -*/ - - -/* display help */ -if ($_POST["ok"]=="Hilfe") { - echo "
Die erste Zeile enthält keine Feldnamen der Daten.
"; - echo "Die Datenfelder haben eine feste Breite.

"; - echo "Die Daten können hier bezogen werden:
"; - echo ""; - echo "http://www.bundesbank.de/zahlungsverkehr/zahlungsverkehr_bankleitzahlen_download.php"; - exit(0); -} else if ($_POST) { - function ende($nr) { - echo "Abbruch: $nr
"; - echo "Fehlende oder falsche Daten."; - exit(1); - } - - function l2u($str) { - return iconv("ISO-8859-1", "UTF-8",$str); - } - - require ("import_lib.php"); - - if (!$_SESSION["db"]) { - $conffile="../config/lx_office.conf"; - if (!is_file($conffile)) { - ende(4); - } - if (!anmelden()) ende(5); - } - - - /* get DB instance */ - $db=$_SESSION["db"]; - - $test=$_POST["test"]; - - clearstatcache (); - - /* no data? */ - if (empty($_FILES["Datei"]["name"])) - ende (2); - - /* copy file */ - if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],"blz.txt")) { - print_r($_FILES); - echo $_FILES["Datei"]["tmp_name"]; - echo "Upload von Datei fehlerhaft."; - echo $_FILES["Datei"]["error"], "
"; - ende (2); - } - - /* check if file is really there */ - if (!file_exists("blz.txt")) - ende(3); - - $sqlins="INSERT INTO blz_data (blz,fuehrend,bezeichnung,plz,ort,kurzbez,pan,bic,pzbm,nummer,aekz,bl,folgeblz) "; - $sqlins.="VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,'%s','%s','%s')"; - $teststr="%s%s%s%s%s%s%s"; - $teststr.="%s%s%d%s%s%s\n"; - $sqldel="delete from blz_data"; - $ok="true"; - $cnt=0; - $f=fopen("blz.txt","r"); - if ($test) echo "Testdurchlauf
\n"; - $i=0; - $start=time(); - $rs = $db->getAll("SELECT current_setting('server_encoding')"); - $srvencoding = $rs[0]['current_setting']; - $rs = $db->getAll("SELECT current_setting('client_encoding')"); - $cliencoding = $rs[0]['current_setting']; - echo "SRV: $srvencoding - - CLI: $cliencoding
"; - if ($f) { - //Cliententcoding auf Latin: - if (!$test) { $rc=$db->query("BEGIN"); if ($cliencoding=="UTF8") $db->query("SET CLIENT_ENCODING TO 'latin-9'"); }; - if (!$test) $rc=$db->query($sqldel); - while (($zeile=fgets($f,256)) != FALSE) { - $cnt++; - if (!$test){ - //Datenfile ist immer Latin!! - //zwei Möglichkeiten der Zeichenwandlung. Was ist besser?? - //Client nicht umgestellt, Zeichen wandeln - /*$sql=sprintf($sqlins,substr($zeile,0,8),substr($zeile,8,1),l2u(substr($zeile,9,58)),substr($zeile,67,5), - l2u(substr($zeile,72,35)),l2u(substr($zeile,107,27)),substr($zeile,134,5),substr($zeile,139,11), - substr($zeile,150,2),substr($zeile,152,6),substr($zeile,158,1),substr($zeile,159,1), - substr($zeile,160,8));*/ - //Client umgestellt + und auch bei nicht UTF-Client: - $sql=sprintf($sqlins,substr($zeile,0,8),substr($zeile,8,1),substr($zeile,9,58),substr($zeile,67,5), - substr($zeile,72,35),substr($zeile,107,27),substr($zeile,134,5),substr($zeile,139,11), - substr($zeile,150,2),substr($zeile,152,6),substr($zeile,158,1),substr($zeile,159,1), - substr($zeile,160,8)); - $rc=$db->query($sql); - if(DB::isError($rc)) { - echo $sql."
";
-					echo $rc->getMessage()."

"; - $ok=false; - break; - } - if ($cnt % 10 == 0) { - if ($cnt % 1000 == 0) { $x=time()-$start; echo sprintf("%dsec %6d
",$x,$cnt); } - else if ($cnt % 100 == 0) { echo "!"; } - else { echo '.'; } - flush(); - } - } else { - echo sprintf($teststr,substr($zeile,0,8),substr($zeile,8,1),l2u(substr($zeile,9,58)),substr($zeile,67,5), - l2u(substr($zeile,72,35)),l2u(substr($zeile,107,27)),substr($zeile,134,5),substr($zeile,139,11), - substr($zeile,150,2),substr($zeile,152,6),substr($zeile,158,1),substr($zeile,159,1), - substr($zeile,160,8)); - $rc=true; - } - if (!$rc) { - $ok=false; - break; - } - $i++; - } - if ($ok) { - if (!$test) $rc=$db->query("COMMIT"); - echo "
$i Daten erfolgreich importierti
"; - if ($cliencoding=="UTF8") $db->query("SET CLIENT_ENCODING TO 'UTF8'"); - $stop=time(); - echo $stop-$start." Sekunden"; - } else { - if (!$test) $rc=$db->query("ROLLBACK"); - echo "Fehler in Zeile: ".$i."
"; - echo $sql."
"; - ende(6); - } - } else { - ende(4); - } - echo "

Fertig. $i Banken importiert."; -} else { -?> -

BLZ-Import für die ERP

-
Die erste Zeile enthält keine Feldnamen der Daten.
-Die Datenfelder haben eine feste Breite.

-Die Daten können hier bezogen werden:
- -http://www.bundesbank.de/zahlungsverkehr/zahlungsverkehr_bankleitzahlen_download.php

-Das File vorher nicht auf UTF8 wandeln!

-Achtung!! Die bestehenden BLZ-Daten werden zunächst gelöscht. -
-

- - - - - - -
Testja
Daten
-
- diff --git a/lxo-import/contactB.php b/lxo-import/contactB.php deleted file mode 100644 index f0b286805..000000000 --- a/lxo-import/contactB.php +++ /dev/null @@ -1,290 +0,0 @@ - - - -"; - echo "Feldname => Bedeutung
"; - foreach($contact as $key=>$val) { - echo "$key => $val
"; - } - exit(0); - }; - - clearstatcache (); - - $trenner=($_POST["trenner"])?$_POST["trenner"]:","; - if ($trenner=="other") { - $trenner=trim($trennzeichen); - if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); - } - - -if (!empty($_FILES["Datei"]["name"])) { - $file=$_POST["ziel"]; - 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($dir.$_POST["ziel"]."_contact.csv")) { - $file=$_POST["ziel"]; -} else { - $file=false; -} - -if (!$file) ende (2); - -if (!file_exists($dir.$file."_contact.csv")) ende(5); - -//$prenumber=$_POST["prenumber"]; - -$employee=chkUsr($_SESSION["employee"]); -if (!$employee) ende(4); - -if (!$db->chkcol($file)) ende(6); - - //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; - -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); -while (!feof($f)){ - $i=-1; - $firma=""; - $name=false; - $id=false; - $sql="insert into contacts "; - $keys="("; - $vals=" values ("; - unset($extra); - $extra = array(); - foreach($zeile as $data) { - $i++; - if (!in_array($in_fld[$i],$kunde_fld)) { - continue; - } - $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"]; - } - continue; - } else if ($in_fld[$i]=="firma") { - continue; - } ; - if ($in_fld[$i]=="cp_cv_id" && $data) { - $data=chkKdId($data); - if ($data) { - $id = $data; - }; - continue; - } 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); - if ($tmp) { - $id=$tmp; - } - } - continue; - } else if ($in_fld[$i]==$file."number") { - continue; - } - if ($in_fld[$i]=="cp_id" && $data) { - $tmp=chkContact($data); - if ($tmp) { - $keys.="cp_id,"; - $vals.="$tmp,"; - } - continue; - } else if ($in_fld[$i]=="cp_id") { - continue; - } - - $keys.=$in_fld[$i].","; - - if ($data==false or empty($data) or !$data) { - $vals.="null,"; - } else { - - 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) { - $zeile=fgetcsv($f,1200,$trenner); - continue; - } - 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 { - $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++; - }; - $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 - Semikolon - Komma - Tabulator - Leerzeichen - - -
Testja
Daten
Verwendete
Zeichecodierung
- -
- - diff --git a/lxo-import/customer.bsp b/lxo-import/customer.bsp deleted file mode 100644 index 574cfa247..000000000 --- a/lxo-import/customer.bsp +++ /dev/null @@ -1,2 +0,0 @@ -name;department_1;department_2;street;zipcode;city;country;contact;phone;fax;homepage;email;notes;discount;taxincluded;terms;customernumber;taxnumber;ustid;account_number;bank_code;bank;branche;sw;creditlimit -Import Kunde;;;Am Weg 3;12345;Sonstwo;D;Fr. Werner;01234123;;www.test.xx;info@test.xx;Hallole;;;;;;;2222;11223344;Meine Bank;Dienstleistung;; diff --git a/lxo-import/customer_contact.bsp b/lxo-import/customer_contact.bsp deleted file mode 100644 index 9bacbcee9..000000000 --- a/lxo-import/customer_contact.bsp +++ /dev/null @@ -1,2 +0,0 @@ -customernumber;cp_cv_id;firma;cp_abteilung;cp_position;cp_gender;cp_title;cp_givenname;cp_name;cp_email;cp_phone1;cp_phone2;cp_mobile1;cp_mobile2;cp_homepage;cp_street;cp_country;cp_zipcode;cp_city;cp_privatphone;cp_privatemail;cp_notes;cp_stichwort1;cp_id -;;Import Kunde;Verwaltung;Leiter;m;Dr.;Hans Heinrich;Import;;;;;;;;D;12345;Sonstwo;;;; diff --git a/lxo-import/customer_shipto.bsp b/lxo-import/customer_shipto.bsp deleted file mode 100644 index b3ecdb53a..000000000 --- a/lxo-import/customer_shipto.bsp +++ /dev/null @@ -1,2 +0,0 @@ -firma;shiptoname;shiptodepartment_1;shiptodepartment_2;shiptostreet;shiptozipcode;shiptocity;shiptocountry;shiptocontact;shiptophone;shiptofax;shiptoemail;customernumber -Import Kunde;Import Kunde;Lagerhaus;;Bahnhofstr. 4;12345;Sonstwo;D;Hr. Hansen;0293948;lager@firma.false; diff --git a/lxo-import/db.php b/lxo-import/db.php deleted file mode 100644 index a7b030d4e..000000000 --- a/lxo-import/db.php +++ /dev/null @@ -1,159 +0,0 @@ -path."lxcrm".date("w").".err","a"); - fputs($efh,date("Y-m-d H:i:s ->")); - fputs($efh,$sql."\n"); - fputs($efh,$err."\n"); - fputs($efh,print_r($this->rc,true)); - fputs($efh,"\n"); - fclose($efh); - if ($this->showErr) - echo "$sql : $err
"; - } - - function showDebug($sql) { - echo $sql."
"; - if ($this->debug==2) { - echo "
";
-            print_r($this->rc);
-            echo "
"; - }; - } - - function writeLog($txt) { - if ($this->lfh===false) - $this->lfh=fopen($this->path."lxcrm".date("w").".log","a"); - fputs($this->lfh,date("Y-m-d H:i:s ->")); - fputs($this->lfh,$txt."\n"); - fputs($this->lfh,print_r($this->rc,true)); - fputs($this->lfh,"\n"); - } - - function closeLogfile() { - fclose($this->lfh); - } - - function myDB($host,$user,$pwd,$db,$port,$showErr=false) { - $dsn = array( - 'phptype' => 'pgsql', - 'username' => $user, - 'password' => $pwd, - 'hostspec' => $host, - 'database' => $db, - 'port' => $port - ); - $this->showErr=$showErr; - $this->db=DB::connect($dsn); - if (!$this->db || DB::isError($this->db)) { - if ($this->log) $this->writeLog("Connect $dns"); - $this->dbFehler("Connect ".print_r($dsn,true),$this->db->getMessage()); - die ($this->db->getMessage()); - } - if ($this->log) $this->writeLog("Connect: ok "); - return $this->db; - } - - function query($sql) { - $this->rc=@$this->db->query($sql); - if ($this->debug) $this->showDebug($sql); - if ($this->log) $this->writeLog($sql); - if(DB::isError($this->rc)) { - $this->dbFehler($sql,$this->rc->getMessage()); - $this->rollback(); - return false; - } else { - return $this->rc; - } - } - - function begin() { - $this->query("BEGIN"); - } - function commit() { - $this->query("COMMIT"); - } - function rollback() { - $this->query("ROLLBACK"); - } - - function getAll($sql) { - $this->rc=$this->db->getAll($sql,DB_FETCHMODE_ASSOC); - if ($this->debug) $this->showDebug($sql); - if ($this->log) $this->writeLog($sql); - if(DB::isError($this->rc)) { - $this->dbFehler($sql,$this->rc->getMessage()); - return false; - } else { - return $this->rc; - } - } - - function saveData($txt) { - if (get_magic_quotes_gpc()) { - return $txt; - } else { - return DB::quoteSmart($string); - } - } - - function execute($statement, $data){ - $sth = $this->db->prepare($statement); //Prepare - /*if (PEAR::isError($sth)) { - $this->dbFehler($statement,$sth->getMessage()); - $this->rollback(); - return false; - }*/ - $rc = $this->db->execute($sth,$data); - if(PEAR::isError($rc)) { - $this->dbFehler(print_r($data,true),$rc->getMessage()."\n".print_r($rc,true)); - $this->rollback(); - return false; - } - $this->db->commit(); - return true; - } - - 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; }; - } - - /** - * Zeichekodirung der DB ermitteln - * - * @return String - */ - function getServerCode() { - $sql="SHOW server_encoding"; - $rs = $this->getAll($sql); - return $rs[0]["server_encoding"]; - } - function getClientCode() { - $sql="SHOW client_encoding"; - $rs = $this->getAll($sql); - return $rs[0]["client_encoding"]; - } - function setClientCode($encoding) { - $sql="SET client_encoding = '$encoding'"; - $rc = $this->query($sql); - return $rc; - } - -} -?> diff --git a/lxo-import/import_lib.php b/lxo-import/import_lib.php deleted file mode 100644 index ac569e813..000000000 --- a/lxo-import/import_lib.php +++ /dev/null @@ -1,444 +0,0 @@ - "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", - "ustid" => "Umsatzsteuer-ID", - "account_number" => "Kontonummer", - "bank_code" => "Bankleitzahl", - "bank" => "Bankname", - "branche" => "Branche", - "business_id" => "BranchenID", - "salesman_id" => "VerkäuferID", - //"language" => "Sprache (de,en,fr)", - "sw" => "Stichwort", - "creditlimit" => "Kreditlimit (nnnnnn.nn)"); /*, - "hierarchie" => "Hierarchie", - "potenzial" => "Potenzial", - "ar" => "Debitorenkonto", - "ap" => "Kreditorenkonto", - "matchcode" => "Matchcode", - "customernumber2" => "Kundennummer 2"); - Kundenspezifisch */ - -$shiptos = array( - "firma" => "Firmenname", - "shiptoname" => "Liefername", - "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", - "ean" => "Barcode", - "description" => "Artikeltext", - "unit" => "Einheit", - "weight" => "Gewicht in Benutzerdefinition", - "notes" => "Beschreibung", - "notes1" => "Beschreibung", - "formel" => "Formel", - "makemodel" => "Hersteller", - "model" => "Modellbezeichnung", - "image" => "Pfad/Dateiname", - "drawing" => "Pfad/Dateiname", - "microfiche" => "Pfad/Dateiname", - "listprice" => "Listenpreis", - "sellprice" => "Verkaufspreis", - "lastcost" => "letzter EK", - "art" => "Ware/Dienstleistung (*/d), muß vor den Konten kommen", - "inventory_accno" => "Bestandskonto", - "income_accno" => "Erlöskonto", - "expense_accno" => "Konto Umsatzkosten", - "obsolete" => "Gesperrt (Y/N)", - "lastcost" => "letzer EK-Preis", - "rop" => "Mindestbestand", - "shop" => "Shopartikel (Y/N)", - "assembly" => "Stückliste (Y/N); wird noch nicht unterstützt", - "partsgroup" => "Warengruppenbezeichnung", - "partsgroup1" => "2.Warengruppenbezeichnung", - "partsgroup2" => "3.Warengruppenbezeichnung", - "partsgroup3" => "4.Warengruppenbezeichnung", - "partsgroup4" => "5.Warengruppenbezeichnung", - "shop" => "Shopexport vorghesehen", - ); - -$contactscrm = array( - "customernumber" => "Kundennummer", - "vendornumber" => "Lieferantennummer", - "cp_cv_id" => "FirmenID in der db", - "firma" => "Firmenname", - "cp_abteilung" => "Abteilung", - "cp_position" => "Position/Hierarchie", - "cp_gender" => "Geschlecht (m/f)", - "cp_title" => "Titel", - "cp_givenname" => "Vorname", - "cp_name" => "Nachname", - "cp_email" => "eMail", - "cp_phone1" => "Telefon 1", - "cp_phone2" => "Telefon 2", - "cp_mobile1" => "Mobiltelefon 1", - "cp_mobile2" => "Mobiltelefon 2", - "cp_homepage" => "Homepage", - "cp_street" => "Strasse", - "cp_country" => "Land", - "cp_zipcode" => "PLZ", - "cp_city" => "Ort", - "cp_privatphone" => "Privattelefon", - "cp_privatemail" => "private eMail", - "cp_notes" => "Bemerkungen", - "cp_stichwort1" => "Stichwort(e)", - "cp_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", - "cp_mobile1" => "Mobiltelefon 1", - "cp_mobile2" => "Mobiltelefon 2", - "cp_privatphone" => "Privattelefon", - "cp_privatemail" => "private eMail", - "cp_homepage" => "Homepage", - "cp_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->begin(); - $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 chkContact($id) { - global $db; - $sql="select * from contact where cp_id = $id"; - $rs=$db->getAll($sql); - if ($rs[0]["cp_id"]==$id) { - return true; - } else { - return false; - } -} - -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"]; -} -/** - * TODO: short description. - * - * @param mixed $tab - * @param object $own - * @param mixed $fld - * @param mixed $val - * - * @return TODO - */ -function insertExtra($tab,$own,$fld,$val) { - global $db; - $sql = "insert into extra_felder (fkey,fval,tab,owner) "; - $sql.= "values ('$fld','$val','$tab','$own')"; - $rc = $db->query($sql); - return $rc; -} -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=str_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"]); - } -} - - -//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=str_replace(" ","%",$nummer); - $sql="select id,".$tabelle."number from $tabelle where upper(".$tabelle."number) like '$nr'"; - $rs=$db->getAll($sql); - if ($rs) { - $nr=str_replace(" ","",$nummer); - foreach ($rs as $row) { - $tmp=str_replace(" ","",$row[$tabelle."number"]); - if ($tmp==$nr) return $row["id"]; - } - } else { - return false; - } - } else { - return $rs[0]["id"]; - } -} - -function getAllBG($db) { - $sql = "select * from buchungsgruppen order by description"; - $rs=$db->getAll($sql); - return $rs; -} - -function getAllUnits($db,$type) { - $sql = "select * from units where type = '$type' order by sortkey"; - $rs=$db->getAll($sql); - return $rs; -} - -function anmelden($login=false,$pwd=false) { - ini_set("gc_maxlifetime","3600"); - if (file_exists("../config/lx_office.conf")) { - $lxo = fopen("../config/lx_office.conf","r"); - } else if (file_exists("../config/lx_office.conf.default")) { - $lxo = fopen("../config/lx_office.conf.default","r"); - } else { - return false; - } - $dbsec = false; - $tmp = fgets($lxo,512); - while (!feof($lxo)) { - if (preg_match("/^[\s]*#/",$tmp)) { - $tmp = fgets($lxo,512); - continue; - } - if ($dbsec) { - preg_match("/db[ ]*= (.+)/",$tmp,$hits); - if ($hits[1]) $dbname=$hits[1]; - preg_match("/password[ ]*= (.+)/",$tmp,$hits); - if ($hits[1]) $dbpasswd=$hits[1]; - preg_match("/user[ ]*= (.+)/",$tmp,$hits); - if ($hits[1]) $dbuser=$hits[1]; - preg_match("/host[ ]*= (.+)/",$tmp,$hits); - if ($hits[1]) $dbhost=($hits[1])?$hits[1]:"localhost"; - preg_match("/port[ ]*= (.+)/",$tmp,$hits); - if ($hits[1]) $dbport=($hits[1])?$hits[1]:"5432"; - if (preg_match("/\[[a-z]+/",$tmp)) break; - $tmp = fgets($lxo,512); - continue; - } - preg_match("/[ ]*cookie_name[ ]*=[ ]*(.+)/",$tmp,$hits); - if ($hits[1]) $cookiename=$hits[1]; - if (preg_match("!\[authentication/database\]!",$tmp)) $dbsec = true; - $tmp = fgets($lxo,512); - } - if (!$cookiename) $cookiename='lx_office_erp_session_id'; - $cookie=$_COOKIE[$cookiename]; - if ($login) { - $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,false,$login,$pwd); - } else { - $cookie=$_COOKIE[$cookiename]; - if (!$cookie) header("location: ups.html"); - $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie,false,false); - }; - if (!$auth) { return false; }; - $_SESSION["sessid"]=$cookie; - $_SESSION["cookie"]=$cookiename; - $_SESSION["employee"]=$auth["login"]; - $_SESSION["mansel"]=$auth["dbname"]; - $_SESSION["dbname"]=$auth["dbname"]; - $_SESSION["dbhost"]=(!$auth["dbhost"])?"localhost":$auth["dbhost"]; - $_SESSION["dbport"]=(!$auth["dbport"])?"5432":$auth["dbport"]; - $_SESSION["dbuser"]=$auth["dbuser"]; - $_SESSION["dbpasswd"]=$auth["dbpasswd"]; - $_SESSION["db"]=new myDB($_SESSION["dbhost"],$_SESSION["dbuser"],$_SESSION["dbpasswd"],$_SESSION["dbname"],$_SESSION["dbport"],$showErr); - $_SESSION["authcookie"]=$authcookie; - $sql="select * from employee where login='".$auth["login"]."'"; - $rs=$_SESSION["db"]->getAll($sql); - if(!$rs) { - return false; - } else { - if ($rs) { - $tmp=$rs[0]; - $_SESSION["termbegin"]=(($tmp["termbegin"]>=0)?$tmp["termbegin"]:8); - $_SESSION["termend"]=($tmp["termend"])?$tmp["termend"]:19; - $_SESSION["Pre"]=$tmp["pre"]; - $_SESSION["interv"]=($tmp["interv"]>0)?$tmp["interv"]:60; - $_SESSION["loginCRM"]=$tmp["id"]; - $_SESSION["lang"]=$tmp["countrycode"]; //"de"; - $_SESSION["kdview"]=$tmp["kdview"]; - $sql="select * from defaults"; - $rs=$_SESSION["db"]->getAll($sql); - $_SESSION["ERPver"]=$rs[0]["version"]; - return true;$_SESSION; - } else { - return false; - } - } -} - -function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie,$login,$pwd) { - $db=new myDB($dbhost,$dbuser,$dbpasswd,$dbname,$dbport,true); - if ($cookie) { - $sql="select sc.session_id,u.id from auth.session_content sc left join auth.user u on "; - $sql.="('--- ' || u.login || E'\\n')=sc.sess_value left join auth.session s on s.id=sc.session_id "; - $sql.="where session_id = '$cookie' and sc.sess_key='login'";// order by s.mtime desc"; - $rs=$db->getAll($sql,"authuser_1"); - if (!$rs) return false; - $stmp=""; - if (count($rs)>1) { - foreach($rs as $row) { - $stmp.=$row["session_id"].","; - } - $sql1="delete from session where id in (".substr($stmp,-1).")"; - $sql2="delete from session_content where session_id in (".substr($stmp,-1).")"; - $db->query($sql1,"authuser_A"); - $db->query($sql2,"authuser_B"); - header("location:../login.pl?action=logout"); - }; - $sql="update auth.session set mtime = '".date("Y-M-d H:i:s.100001")."' where id = '".$rs[0]["session_id"]."'"; - $db->query($sql,"authuser_3"); - $sql="select * from auth.user where id=".$rs[0]["id"]; - } else { - $sql = "select * from auth.user where login = '$login' and password = '$pwd'"; - } - $rs1=$db->getAll($sql,"authuser_1"); - if (!$rs1) return false; - $auth=array(); - $auth["login"]=$rs1[0]["login"]; - $sql="select * from auth.user_config where user_id=".$rs1[0]["id"]; - $rs1=$db->getAll($sql,"authuser_2"); - $keys=array("dbname","dbpasswd","dbhost","dbport","dbuser"); - foreach ($rs1 as $row) { - if (in_array($row["cfg_key"],$keys)) { - $auth[$row["cfg_key"]]=$row["cfg_value"]; - } - } - return $auth; -} - -/** - * Zeichencode übersetzen - * - * @param String $txt - */ -function translate(&$txt) { - if (Auto) { - $encoding = mb_detect_encoding($data,"UTF-8,ISO-8859-1,ISO-8859-15,Windows-1252,ASCII"); - $txt = iconv("$encoding",ServerCode."//TRANSLIT",$txt); - //$txt = mb_convert_encoding($txt, ServerCode,"$encoding"); - } else { - $txt = iconv(FileCode,ServerCode."//TRANSLIT",$txt); - //$txt = mb_convert_encoding($txt, ServerCode,FileCode); - } -} - -?> diff --git a/lxo-import/parts.bsp b/lxo-import/parts.bsp deleted file mode 100644 index ccab0d083..000000000 --- a/lxo-import/parts.bsp +++ /dev/null @@ -1,4 +0,0 @@ -"partnumber" "ean" "description" "unit" "weight" "notes" "makemodel" "model" "image" "sellprice" "lastcost" "partsgroup" "partsgroup1" "partsgroup2" "partsgroup3" "rop" "partsgroup4" "income_accno" "expense_accno" "microfiche" "art" -"TI12346" 92384754671 "Importartikel 1" "Stck" 2 "Die Beschreibung zum Artikel" "Lx-System" "LX123" 10 6 "Hardware" "Test" 1.10 184 37 "Mfiche 1" "W" -"TI12345" 92384754672 "Importartikel 2" 3,1 "Die Beschreibung zum Artikel" "Lx-System" "LX124" 13 8,1 "Hardware" "Test" 184 37 "y" "W" -"TD2345" "Import Diestleistung" "Std" 125 184 37 "D" diff --git a/lxo-import/partsB.php b/lxo-import/partsB.php deleted file mode 100644 index 4a3c7e48e..000000000 --- a/lxo-import/partsB.php +++ /dev/null @@ -1,243 +0,0 @@ - - - - - -Holger Lindemann -*/ - -$dir="../users/"; -$gz_bin = "/bin/gzip -df "; -$zip_bin = "/usr/bin/unzip -o -d ".$dir; - -function ende($txt) { - echo "Abbruch: $txt
"; - exit(1); -} - -if (!$_SESSION["db"]) { - $conffile="../config/lx_office.conf"; - if (!is_file($conffile)) { - ende("lx_office.conf nicht gefunden oder kein Leserecht."); - } -} -require ("import_lib.php"); - -if ($_GET["login"]) { - $db = anmelden($_GET["login"],$_GET["passwd"]); -} else { - $db = anmelden(); -} -//if (!$_SESSION["db"]) ende("Anmeldung fehlgeschlagen."); -if (!$db) ende("Anmeldung fehlgeschlagen."); - -/* get DB instance */ -$db=$_SESSION["db"]; //new myDB($login); -/* just display page or do real import? */ -if ($_POST["ok"] || $_GET["cron"]=="1") { - - require ("parts_import.php"); - //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 Maschine 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"]); - } - } - - /* display help */ - if ($_POST["ok"]=="Hilfe") { - echo "Importfelder:
"; - echo "Feldname => Bedeutung
"; - foreach($parts as $key=>$val) { - echo "$key => $val
"; - } - $header=implode(";",array_keys($parts)); - echo $header; - echo "

Die erste Zeile enthält die Feldnamen der Daten in ihrer richtigen Reihenfolge
"; - echo "Geben Sie das Trennzeichen der Datenspalten ein. Steuerzeichen können mit ihrem Dezimalwert "; - echo "geführt von einem "#" eingegebn werden (#11).

"; - echo "Wird bei "Art" in der Maske "gemischt" gewählt, muss die Spalte "art" vor der Einheit stehen.

"; - echo "Der "sellprice" kann um den eingegeben Wert geändert werden.

"; - echo "Bei vorhandenen Artikelnummern (in der db), kann entweder ein Update auf den Preis (und Text) durchgeführt werden oder "; - echo "der Artikel mit anderer Artikelnummer eingefügt werden.

"; - echo "Jeder Artikel muß einer Buchungsgruppe zugeordnet werden. "; - echo "Dazu muß entweder in der Maske eine Standardbuchungsgruppe gewählt werden
"; - echo "oder es wird ein gültiges Konto in 'income_accno_id' und 'expense_accno_id' eingegeben. "; - echo "Das Programm versucht dann eine passende Buchungsgruppe zu finden.
"; - echo "Preisgruppen müssen zunächst angelegt werden. Die Spalten für die Preisgruppen beginnen mit 'pg_' gefolgt vom Preisgruppenname.
"; - echo "Wenn eine Datei users/partshead.csv existiert, wird die erste Zeile aus dieser benutzt um das Format zu bestimmen. Die erste Zeile aus der eigentlichen Importdatei wird dann ignoriert.
"; - exit(0); - }; - - clearstatcache (); - - $file = "parts"; - - if ($_GET["cron"]==1) { - $Cron = True; - if (file_exists($dir.$file.".zip")) { - exec ($zip_bin.$dir.$file.".zip"); - } else if (file_exists($dir.$file.".gz")) { - exec ($gz_bin.$dir.$file.".csv.gz"); - } else if (!file_exists($dir.$file.".csv")) { - ende($dir.$file.".csv nicht gefunden"); - } - $_POST["trenner"] = "#9"; // Tabulator - $_POST["trennzeichen"] = ";"; // Anderes Trennzeichen - $_POST["dimensionunit"] = "Stck"; // Artikeleinheit - $_POST["serviceunit"] = "Std"; // Dienstleistungseinheit - $_POST["bugru"] = "1600"; // Std-Bugru - $_POST["bugrufix"] = "2"; // Nur wenn keine Passende angegeben - $_POST["shop"] = "f"; // Shopartikel - $_POST["show"] = ""; // Kontrollausgabe - $_POST["test"] = ""; // Testlauf == 1 - $_POST["lager"] = ""; // Nicht gebraucht - $_POST["lagerplatz"] = ""; - $_POST["precision"] = "2"; // Runden auf nn Stellen - $_POST["quotation"] = ""; // Preisaufschlag - $_POST["quottype"] = "P"; // Prozent? - $_POST["wgtrenner"] = "!"; // Trennzeichen der Warengruppen - $_POST["TextUpd"] = "1"; // Textupdate durchführen - $_POST["update"] = "U"; // Bei vorhandenen Nummer updaten - $_POST["ware"] = "W"; // Ist ein Artikel - $_POST["encoding"] = ""; - } else { - - /* no data? */ - if (empty($_FILES["Datei"]["name"])) - ende ("Kein Datenfile angegeben"); - - /* copy file */ - if (substr($_FILES["Datei"]["name"],-2)=="gz") { - if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv.gz")) { - echo $gz_bin.$dir.$file.".csv.gz"; - exec ($gz_bin.$dir.$file.".csv.gz"); - } else { - ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]); - }; - } else if (substr($_FILES["Datei"]["name"],-3)=="zip") { - if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".zip")) { - exec ($zip_bin.$dir.$file.".zip"); - } else { - ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]); - }; - } else if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv")) { - ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]); - }; - } - - /* check if file is really there */ - if (!file_exists($dir.$file.'.csv') or filesize($dir.$file.'.csv')==0) - ende("Datenfile ($file.csv) nicht im Ordner gefunden oder leer"); - - /* Zu diesem Zeitpunkt wurde der Artikel Importiert */ - if (!$db->chkcol($file)) - ende("Importspalte konnte nicht angelegt werden"); - - /* just print data or insert it, if test is false */ - import_parts($_SESSION["db"], $dir.$file, $parts, FALSE, $_POST); - -} else { - $bugrus=getAllBG($db); - $serviceunit=getAllUnits($db,"service"); - $dimensionunit=getAllUnits($db,"dimension"); -?> - -

Artikelimport für die ERP

-
-

- - - - - - - - - - - - - - - - - - - - - -
Trennzeichen - Semikolon - Komma - Tabulator - Leerzeichen - - -
VK-Preis
Nachkomma:
0 - 1 - 2 - 3 - 4 - 5 -
VK-Preis
Aufschlag:
- % - Absolut
Vorhandene
Artikelnummer:
Preis update durchführen
- mit neuer Nummer einfügen
Kontollausgabeja
Testja
Textupdateja
Warengruppen
verbinder
Shopartikel
falls nicht übergeben
ja nein
Eintrag in
Makemodel ist
Lieferantennummer Lieferantenname
auch ohne
Model-Nr.
ja nein
ArtWare   - Dienstleistung - gemischt (Spalte 'art' vorhanden)
Default Einheiten
-
Default Bugru
- für alle Artikel verwenden - für Artikel ohne passende Bugru -
Daten
Verwendete
Zeichecodierung
- -
-
- diff --git a/lxo-import/parts_import.php b/lxo-import/parts_import.php deleted file mode 100644 index 94f2b6f15..000000000 --- a/lxo-import/parts_import.php +++ /dev/null @@ -1,550 +0,0 @@ - -//Holger Lindemann - -/** - * Returns ID of a partgroup (or adds a new partgroup entry) - * \db is the database - * \value is the partgroup name - * \add if true and partgroup does not exist yet, we will add it automatically - * \returns partgroup id or "" in case of an error - */ -function getPartsgroupId($db, $value, $add) { - $sql="select id from partsgroup where partsgroup = '$value'"; - $rs=$db->getAll($sql); - if (empty($rs[0]["id"]) && $add) { - $sql="insert into partsgroup (partsgroup) values ('$value')"; - $rc=$db->query($sql); - if (!$rc) - return ""; - return getPartsgroupId($db, $value, 0); - } - return $rs[0]["id"]; -} -function getPricegroup($db) { - $sql="SELECT * from pricegroup"; - $rs=$db->getAll($sql); - $data = false; - if ($rs) foreach ($rs as $row) { - $data["pg_".strtolower($row["pricegroup"])]=$row["id"]; - }; - return $data; -} -function insertParts($db,$insert,$show,$data,$pricegroup) { - if ($show) { - show('',false); - show($data["partnumber"]); show($data["lastcost"]); show($data["sellprice"]); show($data["listprice"]); - show($data["description"]); show(substr($data["notes"],0,25));show($data["ean"]); - show($data["weight"]); show($data["image"]); show($data["partsgroup_id"]); - show($data["buchungsgruppen_id"]);show($data["income_accno"]); show($data["expense_accno"]); - show($data["inventory_accno"]); show($data["microfiche"]); show($data["drawing"]); - show($data["rop"]); show($data["assembly"]); show($data["makemodel"]); - show($data["shop"]); - } - - /*foreach ($data as $key=>$val) { - echo $key.":".gettype($val).":".gettype($data[$key]).":".$val."
"; - }*/ - if ($insert) { - $data["import"]=time(); - $sqlIa = 'INSERT INTO parts ('; - $sqlIa .= 'partnumber,description,notes,ean,unit,'; - $sqlIa .= 'weight,image,sellprice,listprice,lastcost,partsgroup_id,'; - $sqlIa .= 'buchungsgruppen_id,income_accno_id,expense_accno_id,inventory_accno_id,'; - $sqlIa .= 'microfiche,drawing,rop,assembly,shop,makemodel,import) '; - //$sqlIa .= 'VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; - //$rc=$db->execute($sqlIa,$data); - $sqlIa .= "VALUES ('%s','%s','%s','%s','%s',%0.5f,'%s',%0.5f,%0.5f,%0.5f,%d,%d,%d,%d,%d,'%s','%s',%.0f,'%s','%s','%s',%s)"; - $sql = sprintf($sqlIa,$data['partnumber'],$data['description'],$data['notes'],$data['ean'], - $data['unit'],$data['weight'],$data['image'],$data['sellprice'], - $data['listprice'],$data['lastcost'],$data['partsgroup_id'], - $data['buchungsgruppen_id'],$data['income_accno_id'],$data['expense_accno_id'], - $data['inventory_accno_id'],$data['microfiche'],$data['drawing'],$data['rop'], - $data['assembly'],$data['shop'],$data['makemodel'],$data['import']); - $rc = $db->query($sql); - } else { - $rc = true; - } - if ($pricegroup) $ok = insPrices($db,$data["partnumber"],$pricegroup); - if ($show) { - if ($rc) - show('ok'); - else - show('error'); - show(''."\n",false); - } - return $rc; -} -function updPrice($db,$insert,$show,$partnumber,$lastcost,$sellprice,$listprice,$pricegroup,$shop) { - if ($show) { - show('',false); - show($partnumber); show($lastcost); show($sellprice); show($listprice); - } - if ($insert) { - $sqlPr = 'UPDATE PARTS SET '; - $sqlPr .= 'sellprice = ?, listprice = ?, lastcost = ?, shop = ? '; - $sqlPr .= 'WHERE partnumber = ?'; - $rc=$db->execute($sqlPr,array("sellprice"=>$sellprice,"listprice"=>$listprice,"lastcost"=>$lastcost,"shop"=>$shop,"partnumber"=>$partnumber)); - } else { - $rc = true; - } - if ($pricegroup) $ok = insPrices($db,$partnumber,$pricegroup); - if ($show) { - if ($rc) - show('ok'); - else - show('error'); - show(''."\n",false); - } - return $rc; -} -function updParts($db,$insert,$show,$partnumber,$lastcost,$sellprice,$listprice, - $description,$notes,$ean,$weight,$image, - $partsgroup_id,$pricegroup, $shop) { - if ($show) { - show('',false); - show($partnumber); show($lastcost); show($sellprice); show($listprice); - show($description); show(substr($notes,0,25));show($ean); - show($weight); show($image); show($partsgroup_id); - } - if ($insert) { - $sqlUa = 'UPDATE PARTS SET '; - $sqlUa .= 'description = ?, notes = ?, ean = ?, weight = ?, image = ?, '; - $sqlUa .= 'sellprice = ?, listprice = ?, lastcost = ?, partsgroup_id = ?, shop = ? '; - $sqlUa .= 'WHERE partnumber = ?'; - $rc=$db->execute($sqlUa,array($description,$notes,$ean,$weight,$image, - $sellprice,$listprice,$lastcost,$partsgroup_id,$shop,$partnumber)); - } else { - $rc = true; - } - if ($pricegroup) $ok = insPrices($db,$partnumber,$pricegroup); - if ($show) { - if ($rc) - show('ok'); - else - show('error'); - show(''."\n",false); - } - return $rc; -} - -function getMakemodel($db,$check,$hersteller,$model,$partsid,$lastcost,$add=true) { - $sql="select * from makemodel where make = $hersteller and model = '$model' and parts_id = $partsid"; - $rs=$db->getAll($sql); - if (empty($rs[0]["id"]) && $add) { - if (!$lastcost) $lastcost=0.00; - $sql="insert into makemodel (parts_id,make,model,lastcost,lastupdate,sortorder) "; - $sql.="values ($partsid,'$hersteller','$model',$lastcost,now(),1)"; - $rc=$db->query($sql); - } -} - -function getAccnoId($db, $accno) { - $sql = "select id from chart where accno='$accno'"; - $rs=$db->getAll($sql); - return $rs[0]["id"]; -} - -function getPartsid($db,$number) { - $sql = "select id from parts where partnumber = '$number'"; - $rs=$db->getAll($sql); - if ($rs[0]["id"]>0) { - return $rs[0]["id"]; - } else { - return false; - } -} - -function newPartNumber($db,$check) { - if ($check) return "check"; - $rc=$db->query("BEGIN"); - $sql = "select articlenumber from defaults"; - $rs=$db->getAll($sql); - if ($rs[0]["articlenumber"]) { - preg_match("/([^0-9]+)?([0-9]+)([^0-9]+)?/", $rs[0]["articlenumber"] , $regs); - $number=$regs[1].($regs[2]+1).$regs[3]; - } - $sql = "update defaults set articlenumber = '$number'"; - $rc=$db->query($sql); - $rc=$db->query("COMMIT"); - //Prüfen ob die Nummer nicht doch schon vergeben ist. - $sql = "select * from parts where partnumber = '$number'"; - $rs=$db->getAll($sql); - if ($rs[0]["id"]>0) return ""; - return $number; -} - -function getBuchungsgruppe($db, $income, $expense) { - $income_id = getAccnoId($db, $income); - $expense_id = getAccnoId($db, $expense); - $sql = "select id from buchungsgruppen where "; - $sql .= "income_accno_id_0 = $income and "; - $sql .= "expense_accno_id_0 = $expense "; - $sql .= "order by sortkey"; - $rs=$db->getAll($sql); - return $rs[0]["id"]; -} - -function getFromBG($db, $bg_id, $name) { - $sql = "select $name from buchungsgruppen where id='$bg_id'"; - $rs=$db->getAll($sql); - return 1*$rs[0][$name]; -} - -function existUnit($db, $value) { - $sql="select name from units where name = '$value'"; - $rs=$db->getAll($sql); - if (empty($rs[0]["name"])) - return FALSE; - return TRUE; -} - -function show($things,$td=true) { - if ($td) - echo ''.$things.''; - else - echo $things; -} - -function getStdUnit($db,$type) { - $sql="select * from units where type='$type' order by sortkey limit 1"; - $rs=$db->getAll($sql); - return $rs[0]["name"]; -} - -function insPrices($db,$pid,$prices) { - $rc = $db->query("BEGIN"); - $sql="delete from prices where parts_id = (select id from parts where partnumber = '$pid')"; - $rc = $db->query($sql); - $sql = "insert into prices (parts_id,pricegroup_id,price) values ((select id from parts where partnumber = '%s'),%d,%0.5f)"; - foreach ($prices as $key => $val) { - $rc = $db->query(sprintf($sql,$pid,$key,$val)); - if (!$rc) { - $db->query("ROLLBACK"); - return false; - } - } - $db->query("COMMIT"); - return true; -} - -/** - * TODO: short description. - * - * @param double $db - * @param mixed $file - * @param mixed $fields - * @param mixed $check - * @param int $insert - * @param string $show - * @param mixed $maske - * - * @return TODO - */ -function import_parts($db, $file, $fields, $check, $maske) { - $insert = !$maske["test"]; - $show = $maske["show"]; - $trennzeichen = ($maske["trennzeichen"])?$maske["trennzeichen"]:""; - $trenner = ($maske["trenner"])?$maske["trenner"]:","; - $precision=$maske["precision"]; - $quotation=$maske["quotation"]; - $quottype=$maske["quottype"]; - $shop=$maske["shop"]; - $wgtrenner=$maske["wgtrenner"]; - $Update=($maske["update"]=="U")?true:false; - $UpdText=($maske["TextUpd"]=="1")?true:false; - $vendnr=($maske["vendnr"]=="t")?true:false; - $modnr=($maske["modnr"]=="t")?true:false; - - //$stdunitW=getStdUnit($db,"dimension"); - //$stdunitD=getStdUnit($db,"service"); - $stdunitW=$maske["dimensionunit"]; - $stdunitD=$maske["serviceunit"]; - if ($quottype=="P") $quotation=($quotation+100)/100; - - if ($show && !$insert) show("Testimport",false); - if ($show) show("\n",false); - - /* field description */ - $prices = getPricegroup($db); - if ($prices) { - $priceskey = array_keys($prices); - $parts_fld = array_merge(array_keys($fields),$priceskey); - } else { - $parts_fld = array_keys($fields); - } - - if ($trenner=="other") $trenner=trim($trennzeichen); - if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); - - /* open csv file */ - if (file_exists($file."head.csv")) { - $fh=fopen($file.'head.csv',"r"); - // Erst einmal die erste Zeile mit den richtigen Feldbezeichnungen einlesen. - $infld=fgetcsv($fh,1200,$trenner); - fclose($fh); - $f=fopen($file.'.csv',"r"); - // Erst einmal die erste Zeile mit den falschen Feldbezeichnungen einlesen. - $tmp=fgetcsv($f,1200,$trenner); - } else { - $f=fopen($file.'.csv',"r"); - // Erst einmal die erste Zeile mit den Feldbezeichnungen einlesen. - $infld=fgetcsv($f,1200,$trenner); - } - - /* - * read first line with table descriptions - */ - if ($show) { - show('',false); - show("partnumber"); show("lastcost"); show("sellprice"); show("listprice"); - show("description"); show("notes"); show("ean"); - show("weight"); show("image"); show("partsgroup_id"); - show("bg"); show("income_accno"); show("expense_accno"); - show("inventory_accno"); show("microfiche"); show("drawing"); - show("rop"); show("assembly"); show("makemodel"); show("shop"); show(""); - show("\n",false); - } - - - $p=0; - foreach ($infld as $fld) { - $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); - if (in_array($fld,$parts_fld)) { - $fldpos[$fld]=$p; - } - $p++; - } - $i=0; - $u=0; - $m=0; /* line */ - $errors=0; /* number of errors detected */ - $income_accno = ""; - $expense_accno = ""; - $assembly = 'f'; - - while ( ($zeile=fgetcsv($f,120000,$trenner)) != FALSE) { - $m++; /* increase line */ - $unit=false; - unset($pgroup); - unset($partsgroup_id); - unset($notes); - unset($rop); - unset($weight); - unset($inventory_accno); - unset($income_accno); - unset($expense_accno); - unset($model); - unset($makemodel); - unset($hersteller); - - /* VK-Preis bilden */ - $sellprice = str_replace(",", ".", $zeile[$fldpos["sellprice"]]); - $listprice = str_replace(",", ".", $zeile[$fldpos["listprice"]]); - $lastcost = str_replace(",", ".", $zeile[$fldpos["lastcost"]]); - if ($prices) { - foreach ($prices as $pkey=>$val) { - if (array_key_exists($pkey,$fldpos)) - $pricegroup[$val] = str_replace(",", ".", $zeile[$fldpos[$pkey]]); - } - } - if ($quotation<>0) { - if ($quottype=="A") { $sellprice += $quotation; } - else { $sellprice = $sellprice * $quotation; } - }; - if ($lastcost=="") unset($lastcost); - if ($sellprice=="") unset($sellprice); - if ($listprice=="") unset($listprice); - - /* Langtext zusammenbauen */ - if ($zeile[$fldpos["notes"]]) { - //Kundenspezifisch: - //$notes = preg_replace('/""[^ ]/','"',$zeile[$fldpos["notes"]]); - $notes = addslashes($zeile[$fldpos["notes"]]); - if (Translate) translate($notes); - } - if ($zeile[$fldpos["notes1"]]) { - //Kundenspezifisch: - //$notes1 = preg_replace('/""[^ ]/','"',$zeile[$fldpos["notes1"]]); - $notes1 = addslashes($zeile[$fldpos["notes1"]]); - if (Translate) translate($notes1); - if ($notes) { - $notes .= "\n".$notes1; - } else { - $notes = $notes1; - } - } - - /* Warengruppe bilden */ - if ($fldpos["partsgroup"]>0 and $zeile[$fldpos["partsgroup"]]) $pgroup[]=$zeile[$fldpos["partsgroup"]]; - if ($fldpos["partsgroup1"]>0 and $zeile[$fldpos["partsgroup1"]]) $pgroup[]=$zeile[$fldpos["partsgroup1"]]; - if ($fldpos["partsgroup2"]>0 and $zeile[$fldpos["partsgroup2"]]) $pgroup[]=$zeile[$fldpos["partsgroup2"]]; - if ($fldpos["partsgroup3"]>0 and $zeile[$fldpos["partsgroup3"]]) $pgroup[]=$zeile[$fldpos["partsgroup3"]]; - if ($fldpos["partsgroup4"]>0 and $zeile[$fldpos["partsgroup4"]]) $pgroup[]=$zeile[$fldpos["partsgroup4"]]; - if (count($pgroup)>0) { - $pgname = implode($wgtrenner,$pgroup); - if (Translate) translate($pgname); - $partsgroup_id = getPartsgroupId($db, $pgname, $insert); - } - - /* Ware oder Dienstleistung */ - if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="D") or $maske["ware"]=="D") { - $artikel = false; - } else if (($maske["ware"]=="G" and strtoupper($zeile[$fldpos["art"]])=="W") or $maske["ware"]=="W") { - $artikel = true; - } - - /* sind Hersteller und Modelnummer hinterlegt - wenn ja, erfolgt er insert später */ - $makemodel = 'f'; - if (!empty($zeile[$fldpos["makemodel"]]) and $artikel) { - $mm = $zeile[$fldpos["makemodel"]]; - if (Translate) translate($mm); - if ($vendnr) { - $hersteller=getFirma($mm,"vendor"); - } else { - $hersteller=suchFirma("vendor",$mm); - $hersteller=$hersteller["cp_cv_id"]; - } - if (!empty($zeile[$fldpos["model"]]) and $hersteller>0) { - $mo = $zeile[$fldpos["model"]]; - if (Translate) translate($mo); - $model = $mo; - $makemodel = 't'; - } else if ($modnr and $hersteller>0) { - $model = ''; - $makemodel = 't'; - } else { - unset($hersteller); - $makemodel = 'f'; - } - } - - /* Einheit ermitteln */ - if ($zeile[$fldpos["unit"]]=="") { - //Keine Einheit mitgegeben - if ($maske["ware"]=="G") { - if ($artikel) { - $unit = $stdunitD; - } else { - $unit = $stdunitW; - } - } else if ($maske["ware"]=="D") { $unit = $stdunitD; } - else { $unit = $stdunitW; }; - } else { - if (existUnit($db,$zeile[$fldpos["unit"]])) { - $unit = $zeile[$fldpos["unit"]]; - } else { - $unit = ($artikel)?$stdunitD:$stdunitW; - } - } - - /* Buchungsgruppe ermitteln */ - if ($maske["bugrufix"]==1) { - $bg = $maske["bugru"]; - } else { - if ($zeile[$fldpos["income_accno"]]<>"" and $zeile[$fldpos["expense_accno"]]<>"") { - /* search for buchungsgruppe */ - $bg = getBuchungsgruppe($db, $zeile[$fldpos["income_accno"]],$zeile[$fldpos["expense_accno"]]); - if ($bg == "" and $maske["bugrufix"]==2 and $maske["bugru"]<>"") { - $bg = $maske["bugru"]; - } - } else if ($maske["bugru"]<>"" and $maske["bugrufix"]==2) { - $bg = $maske["bugru"]; - } else { - /* nothing found? user must create one */ - echo "Error in line $m: "; - echo "Keine Buchungsgruppe gefunden für
"; - echo "Erlöse Inland: ".$zeile[$fldpos["income_accno"]]."
"; - echo "Aufwand Inland: ".$zeile[$fldpos["expense_accno"]]."
"; - echo "Bitte legen Sie eine an oder geben Sie eine vor.
"; - echo "
"; - $errors++; - } - } - if ($bg > 0) { - /* found one, add income_accno_id etc from buchungsgr. */ - /* XXX nur bei artikel!!! */ - if ($artikel) { - $inventory_accno = getFromBG($db, $bg, "inventory_accno_id"); - }; - $income_accno = getFromBG($db, $bg, "income_accno_id_0"); - $expense_accno = getFromBG($db, $bg, "expense_accno_id_0"); - $bg = $bg * 1; - } else { - echo "Error in line $m: "; - echo "Keine Buchungsgruppe angegeben/gefunden
"; - $errors++; - continue; - } - - $description = preg_replace('/""[^ ]/','"',$zeile[$fldpos["description"]]); - $description = addslashes($description); - if (Translate) translate($description); - - // rop und weight müssen null oder Zahl sein - if ($zeile[$fldpos["rop"]]) $rop = 1 * str_replace(",", ".",$zeile[$fldpos["rop"]]); - if ($zeile[$fldpos["weight"]]) $weight = 1 * str_replace(",", ".", $zeile[$fldpos["weight"]]); - - // Shop-Artikel - if ($zeile[$fldpos["shop"]]) { - $shop = (strtolower($zeile[$fldpos["shop"]]=='t'))?'t':'f'; - } else { - $shop = $maske["shop"]; - } - // Artikel updaten - - if (getPartsid($db,trim($zeile[$fldpos["partnumber"]]))) { - /* es gibt die Artikelnummer */ - if ($Update) { - /* Updates durchführen */ - if ($UpdText=='1') { - $u += updParts($db,$insert,$show,$zeile[$fldpos["partnumber"]],$lastcost,$sellprice,$listprice, - $description,$notes,$zeile[$fldpos["ean"]],$weight, - $zeile[$fldpos["image"]],$partsgroup_id,$pricegroup, $shop); - } else { - $u += updPrice($db,$insert,$show,$zeile[$fldpos["partnumber"]],$lastcost,$sellprice,$listprice,$pricegroup,$shop); - } - continue; - // nächste Zeile - } - } - - // Neuen Artikel einfügen - - if ($zeile[$fldpos["partnumber"]] == "") { - $zeile[$fldpos["partnumber"]] = newPartNumber($db,$check); - //Keine Artikelnummer bekommen - if ($zeile[$fldpos["partnumber"]] == "") { - continue; - } - } - $i += insertParts($db,$insert,$show,array( - "partnumber"=>$zeile[$fldpos["partnumber"]], - "description"=>$description,"notes"=>$notes, - "ean"=>$zeile[$fldpos["ean"]],"unit"=>$unit, - "weight"=>$weight,"image"=>$zeile[$fldpos["image"]], - "sellprice"=>$sellprice, - "lastcost"=>$lastcost, - "listprice"=>$listprice, - "partsgroup_id"=>$partsgroup_id, - "buchungsgruppen_id"=>$bg,"income_accno_id"=>$income_accno, - "expense_accno_id"=>$expense_accno,"inventory_accno_id"=>$inventory_accno, - "microfiche"=>$zeile[$fldpos["microfiche"]],"drawing"=>$zeile[$fldpos["drawing"]], - "rop"=>$rop,"assembly"=>$assembly, - "shop"=>$shop,"makemodel"=>$makemodel),$pricegroup - ); - if ($hersteller>0 ) { // && $model) { - $partsid=getPartsid($db,$zeile[$fldpos["partnumber"]]); - if ($partsid) { - getMakemodel($db,$check,$hersteller,$model,$partsid,$lastcost,true); - } - } - unset($zeile); - } - - if ($show) show("
",false); - fclose($f); - echo "$m Zeilen bearbeitet. Importiert: $i Update: $u (".($m-$u-$i+$errors)." : Fehler) "; -} -?> diff --git a/lxo-import/partshead.csv b/lxo-import/partshead.csv deleted file mode 100644 index 53793b485..000000000 --- a/lxo-import/partshead.csv +++ /dev/null @@ -1 +0,0 @@ -partnumber fvId wgr partsgroup ean model ErsatzArt makemodel MarkeText description cat01 cat01Text cat02 cat02Text cat03 cat03Text cat04 cat04Text KzStueck KzAL KzAktion KzSperre pg_1 pg_2 listprice lastcost InfLagME InfLagWE diff --git a/lxo-import/shiptoB.php b/lxo-import/shiptoB.php deleted file mode 100644 index fc934c394..000000000 --- a/lxo-import/shiptoB.php +++ /dev/null @@ -1,233 +0,0 @@ - - - -"; - echo "Feldname => Bedeutung
"; - foreach($shiptos as $key=>$val) { - echo "$key => $val
"; - } - $header=implode(";",array_keys($shiptos)); - echo $header; - exit(0); - }; - -if (!$_SESSION["db"]) { - $conffile="../config/lx_office.conf"; - if (!is_file($conffile)) { - ende("lx_office.conf nicht gefunden oder unlesbar"); - } -} - -if (!anmelden()) ende("Anmeldung fehlgeschlagen"); - -/* get DB instance */ -$db=$_SESSION["db"]; //new myDB($login); - -$crm=checkCRM(); - -if ($_POST["ok"] == "Import") { - $dir = "../users/"; - - $test=$_POST["test"]; - - $shipto_fld = array_keys($shiptos); - $shipto=$shiptos; - - $nun=time(); - - clearstatcache (); - - $trenner=($_POST["trenner"])?$_POST["trenner"]:","; - if ($trenner=="other") { - $trenner=trim($trennzeichen); - if (substr($trenner,0,1)=="#") if (strlen($trenner)>1) $trenner=chr(substr($trenner,1)); - }; - - if (!empty($_FILES["Datei"]["name"])) { - $file=$_POST["ziel"]; - if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file."_shipto.csv")) { - $file=false; - echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")
"; - } - } else if (is_file($dir.$_POST["ziel"]."_shipto.csv")) { - $file=$_POST["ziel"]; - } else { - $file=false; - } - if (!$file) ende ("Kein Datenfile"); - - if (!file_exists($dir.$file."_shipto.csv")) ende($file."_shipto.csv nicht im Ordner gefunden oder leer"); - - $employee=chkUsr($_SESSION["employee"]); - if (!$employee) ende("Benutzer unbekannt"); - - if (!$db->chkcol($file)) ende("Importspalte konnte nicht angelegt werden"); - //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."_shipto.csv","r"); - $zeile=fgetcsv($f,1000,$trenner); - $first=true; - - foreach ($zeile as $fld) { - $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); - $in_fld[]=$fld; - } - $j=0; - $n=0; - //$prenumber=$_POST["prenumber"]; - $zeile=fgetcsv($f,1000,$trenner); - - while (!feof($f)){ - $i=-1; - $id=false; - $sql="insert into shipto "; - $keys=""; - $vals=""; - foreach($zeile as $data) { - $i++; - if (!in_array($in_fld[$i],$shipto_fld)) { - continue; - } - $data=addslashes(trim($data)); - if ($in_fld[$i]=="trans_id" && $data) { - $data=chkKdId($data); - if (!$id) $id = $data; - continue; - } else if ($in_fld[$i]=="trans_id") { - continue; - } - if ($in_fld[$i]==$file."number" && $data) { - $tmp=getFirma($data,$file); - if ($id<>$tmp) $id=$tmp; - continue; - } else if ($in_fld[$i]==$file."number") { - continue; - } - if ($in_fld[$i]=="firma") { - if ($id) continue; - if (Translate) translate($data); - $data=suchFirma($file,$data); - if ($data) { - $id=$data["cp_cv_id"]; - } - continue; - } - $keys.=$in_fld[$i].","; - - if ($data==false or empty($data) or !$data) { - $vals.="null,"; - } else { - /*if (in_array($in_fld[$i],array("shiptofax","shiptophone"))) { - $data=$prenumber.$data; - } */ - if (Translate) translate($data); - $vals.="'".$data."',"; - // bei jedem gefuellten Datenfeld erhoehen - $val_count++; - } - } - if ($keys<>"" && $id) { - $vals.=$id.",'CT'"; - $keys.="trans_id,module"; - if ($test) { - if ($first) { - echo "\n"; - echo "\n"; - $first=false; - }; - echo "\n"; - flush(); - } else { - $sql.="(".$keys.")"; - $sql.="values (".$vals.")"; - $rc=$db->query($sql); - if (!$rc) echo "Fehler: ".$sql."\n"; - } - $j++; - } - $n++; - $zeile=fgetcsv($f,1000,$trenner); - } - fclose($f); - echo "
".str_replace(",","",$keys)."
".str_replace(",","",$vals)."
".$j." $file shipto von $n importiert.\n"; -} else { -?> -

Lieferanschriftimport für die ERP

-
- - - - - - - - - - -
Zieltabellecustomer vendor
Trennzeichen - Semikolon - Komma - Tabulator - Leerzeichen - - -
Testja
Daten
Verwendete
Zeichecodierung
- -
-
- diff --git a/lxo-import/ups.html b/lxo-import/ups.html deleted file mode 100644 index 0f91e2d3f..000000000 --- a/lxo-import/ups.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -

- Uups! -

-

- Die Session auf dem Server oder das Cookie wurden gelöscht oder sind nicht mehr gültig! -

- - Sie haben eine bestimmte Zeit nicht mehr mit dem System gearbeitet - -

-

- Bitte melden Sie sich neu an oder klicken Sie auf einen Hauptmenüpunkt. -

-
- diff --git a/menu.ini b/menu.ini index 10020f85f..de5ca683b 100644 --- a/menu.ini +++ b/menu.ini @@ -755,24 +755,6 @@ action=list_warehouses #action=import #type=Datapreis -# [System--Import CSV] -# module=menu.pl -# action=acc_menu -# target=acc_menu -# submenu=1 - -# [System--Import CSV--Customer] -# module=lxo-import/addressB.php - -# [System--Import CSV--Contacts] -# module=lxo-import/contactB.php - -# [System--Import CSV--Shipto] -# module=lxo-import/shiptoB.php - -# [System--Import CSV--Parts] -# module=lxo-import/partsB.php - [System--Import CSV] module=menu.pl action=acc_menu -- 2.20.1