X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=lxo-import%2FaddressB.php;h=2341fdd81fa3d4e660d97501057bf7ad25436d76;hb=ee792a3f74896ac23931fc34451d17ec95ac03cd;hp=dcb5adb7f974c22cf37c90beccec14c4ac6d2150;hpb=3e63947841c49112212cdeef5bd178fe961bf002;p=kivitendo-erp.git
diff --git a/lxo-import/addressB.php b/lxo-import/addressB.php
index dcb5adb7f..2341fdd81 100644
--- a/lxo-import/addressB.php
+++ b/lxo-import/addressB.php
@@ -12,62 +12,69 @@ Web: http://lx-system.de
*/
-if ($_GET["login"]) {
- $login=$_GET["login"];
-} else {
- $login=$_POST["login"];
+require ("import_lib.php");
+
+if (!$_SESSION["db"]) {
+ $conffile="../config/authentication.pl";
+ if (!is_file($conffile)) {
+ ende("authentication.pl 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();
-require ("import_lib.php");
-$db=new myDB($login);
+
+/* get DB instance */
+$db=$_SESSION["db"]; //new myDB($login);
+
$crm=checkCRM();
-function ende($nr) {
- echo "Abbruch: $nr
";
- echo "Fehlende oder falsche Daten.";
- exit(1);
+function ende($txt) {
+ echo "Abbruch: $txt
";
+ 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"].")
";
- }
+ $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"];
+ $file=$_POST["ziel"];
} else {
- $file=false;
+ $file=false;
}
-if (!$file) ende (2);
+if (!$file) ende ("Kein Datenfile");
$trenner=($_POST["trenner"])?$_POST["trenner"]:",";
-//echo "../users/$login.conf";
-if (!file_exists("../users/$login.conf")) ende(3);
-if (!file_exists("$file.csv")) ende(5);
+if (!file_exists("$file.csv")) ende("$file.csv nicht im Ordner oder leer");
-$db=new myDB($login);
-if (!$db->chkcol($file)) ende(6);
+if (!$db->chkcol($file)) ende("Importspalte kann nicht angelegt werden");
-$employee=chkUsr($login);
-if (!$employee) ende(4);
+$employee=chkUsr($_SESSION["employee"]);
+if (!$employee) ende("Ungültiger User");
$kunde_fld = array_keys($address);
@@ -77,103 +84,102 @@ $infld=split($trenner,strtolower($zeile));
$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;
+ $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=mb_convert_encoding($data,"ISO-8859-15","auto");
- //$data=htmlentities($data);
- $data=addslashes($data);
- if ($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]=="ustid"){
- $data=strtr(" ","",$data);
- } /*else if ($in_fld[$i]=="matchcode") {
+ $i=0;
+ $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=mb_convert_encoding($data,"ISO-8859-15","auto");
+ //$data=htmlentities($data);
+ $data=addslashes($data);
+ if ($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]=="ustid"){
+ $data=strtr(" ","",$data);
+ } /*else 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) {
- $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 "
".str_replace(","," | ",substr($keys,1,-1))." | ",substr($vals,9,-1)); - echo " |
---|---|
".str_replace("null,","null | ",$vals)." |
".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)." |
Adressimport für die ERP