X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=lxo-import%2Fimport_lib.php;h=ac569e813a2cab0a6830243dc5838d3e140be970;hb=3a56098f9b80397fe27922f1661b2069183aa2d6;hp=2abec363c65e6caa4257f6a6708072ad1b76462a;hpb=fc47e4830133fb0841ae91a63f909ea7ce6d72fe;p=kivitendo-erp.git diff --git a/lxo-import/import_lib.php b/lxo-import/import_lib.php index 2abec363c..ac569e813 100644 --- a/lxo-import/import_lib.php +++ b/lxo-import/import_lib.php @@ -36,6 +36,8 @@ $address = array( "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)"); /*, @@ -71,6 +73,7 @@ $parts = array( "weight" => "Gewicht in Benutzerdefinition", "notes" => "Beschreibung", "notes1" => "Beschreibung", + "formel" => "Formel", "makemodel" => "Hersteller", "model" => "Modellbezeichnung", "image" => "Pfad/Dateiname", @@ -93,6 +96,7 @@ $parts = array( "partsgroup2" => "3.Warengruppenbezeichnung", "partsgroup3" => "4.Warengruppenbezeichnung", "partsgroup4" => "5.Warengruppenbezeichnung", + "shop" => "Shopexport vorghesehen", ); $contactscrm = array( @@ -220,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; @@ -233,7 +253,7 @@ function suchFirma($tab,$data) { if (!$rs) { $org=$data; while(strpos($data," ")>0) { - $data=ereg_replace(" "," ",$data); + $data=str_replace(" "," ",$data); } $data=preg_replace("/[^A-Z0-9]/ ",".*",trim($data)); $sql="select * from $tab where upper(name) ~ '$data'"; @@ -255,13 +275,13 @@ function getFirma($nummer,$tabelle) { $sql="select id from $tabelle where upper(".$tabelle."number) = '$nummer'"; $rs=$db->getAll($sql); if (!$rs) { - $nr=ereg_replace(" ","%",$nummer); + $nr=str_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); + $nr=str_replace(" ","",$nummer); foreach ($rs as $row) { - $tmp=ereg_replace(" ","",$row[$tabelle."number"]); + $tmp=str_replace(" ","",$row[$tabelle."number"]); if ($tmp==$nr) return $row["id"]; } } else { @@ -278,25 +298,57 @@ function getAllBG($db) { return $rs; } -function anmelden() { +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"); - $tmp = @file_get_contents("../config/authentication.pl"); - preg_match("/'db'[ ]*=> '(.+)'/",$tmp,$hits); - $dbname=$hits[1]; - preg_match("/'password'[ ]*=> '(.+)'/",$tmp,$hits); - $dbpasswd=$hits[1]; - preg_match("/'user'[ ]*=> '(.+)'/",$tmp,$hits); - $dbuser=$hits[1]; - preg_match("/'host'[ ]*=> '(.+)'/",$tmp,$hits); - $dbhost=($hits[1])?$hits[1]:"localhost"; - preg_match("/'port'[ ]*=> '?(.+)'?/",$tmp,$hits); - $dbport=($hits[1])?$hits[1]:"5432"; - preg_match("/[ ]*\\\$self->\{cookie_name\}[ ]*=[ ]*'(.+)'/",$tmp,$hits); - $cookiename=$hits[1]; + 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 (!$cookie) header("location: ups.html"); - $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie); + 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; @@ -326,38 +378,43 @@ function anmelden() { $sql="select * from defaults"; $rs=$_SESSION["db"]->getAll($sql); $_SESSION["ERPver"]=$rs[0]["version"]; - return true; + return true;$_SESSION; } else { return false; } } } -function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie) { +function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie,$login,$pwd) { $db=new myDB($dbhost,$dbuser,$dbpasswd,$dbname,$dbport,true); - $sql="select sc.session_id,u.id from auth.session_content sc left join auth.user u on "; - $sql.="u.login=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) { - header("location:../login.pl?action=logout"); - /*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"); - $sql3="insert into session ";*/ + 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'"; } - $sql="select * from auth.user where id=".$rs[0]["id"]; $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=".$rs[0]["id"]; + $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) { @@ -365,9 +422,23 @@ function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie) { $auth[$row["cfg_key"]]=$row["cfg_value"]; } } - $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"); 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); + } +} + ?>