From 6911a9c9d7cfb2a5c363ab2f7c8009bbecf3870d Mon Sep 17 00:00:00 2001 From: Holger Lindemann Date: Wed, 2 Feb 2011 17:25:01 +0100 Subject: [PATCH] =?utf8?q?Extrafelder=20f=C3=BCr=20Kontakte=20in=20CRM=20i?= =?utf8?q?mportieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lxo-import/contactB.php | 25 ++++++++++++++++++++++--- lxo-import/import_lib.php | 18 +++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lxo-import/contactB.php b/lxo-import/contactB.php index 4a157c4f9..5dd8891e5 100644 --- a/lxo-import/contactB.php +++ b/lxo-import/contactB.php @@ -127,6 +127,7 @@ $first=true; foreach ($zeile as $fld) { $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); $in_fld[]=$fld; + if (substr($fld,0,2) == "x_") $kunde_fld[] = $fld; } $j=0; $zeile=fgetcsv($f,2000,$trenner); @@ -138,6 +139,8 @@ while (!feof($f)){ $sql="insert into contacts "; $keys="("; $vals=" values ("; + unset($extra); + $extra = array(); foreach($zeile as $data) { $i++; if (!in_array($in_fld[$i],$kunde_fld)) { @@ -163,6 +166,12 @@ while (!feof($f)){ } else if($in_fld[$i]=="cp_cv_id") { continue; } + if (substr($in_fld[$i],0,2)=="x_" && $data) { + $extra[substr($in_fld[$i],2)] = $data; + continue; + } else if ((substr($in_fld[$i],0,2)=="x_")) { + continue; + }; if ($in_fld[$i]==$file."number" && $data) { if (!$id) { $tmp=getFirma($data,$file); @@ -223,10 +232,20 @@ while (!feof($f)){ echo "".str_replace("null,","null",$vals)."\n"; flush(); } else { - $sql.=substr($keys,0,-1).")"; - $sql.=substr($vals,0,-1).")"; + $newID=uniqid (rand()); + $now = date('Y-m-d H:i').":1.$j"; + $sql.= $keys."mtime)"; + $sql.= $vals."'$now')"; $rc=$db->query($sql); if (!$rc) echo "Fehler: ".$sql."\n"; + $rs = $db->getAll("select cp_id,cp_name from contacts where mtime = '$now'"); + $cp_id = $rs[0]["cp_id"]; + echo "(".$rs[0]["cp_name"].":$cp_id)".count($extra).";"; + if (count($extra)>0 and $cp_id) { + foreach ($extra as $fld=>$val) { + $rc = insertExtra("P",$cp_id,$fld,$val); + } + } } $j++; }; @@ -237,7 +256,7 @@ echo $j." $file importiert.\n";} else { ?>

Kontakt-Adressimport für die ERP

- + diff --git a/lxo-import/import_lib.php b/lxo-import/import_lib.php index 6d9dd879b..eaba7463f 100644 --- a/lxo-import/import_lib.php +++ b/lxo-import/import_lib.php @@ -224,7 +224,23 @@ function getKdRefId($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; -- 2.20.1
Zieltabellecustomer vendor