2 <LINK REL="stylesheet" HREF="../css/lx-office-erp.css" TYPE="text/css" TITLE="Lx-Office stylesheet">
6 Kunden- bzw. Lieferantenimport mit Browser nach Lx-Office ERP
9 Author: Holger Lindemann
10 Email: hli@lx-system.de
11 Web: http://lx-system.de
16 $login=$_GET["login"];
18 $login=$_POST["login"];
24 require ("import_lib.php");
29 echo "Abbruch: $nr<br>";
30 echo "Fehlende oder falsche Daten.";
34 if ($_POST["ok"]=="Hilfe") {
35 echo "Importfelder:<br>";
36 echo "Feldname => Bedeutung<br>";
37 foreach($address as $key=>$val) {
38 echo "$key => $val<br>";
45 if (!empty($_FILES["Datei"]["name"])) {
47 if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file.".csv")) {
49 echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")<br>";
51 } else if (is_file($_POST["ziel"].".csv")) {
59 $trenner=($_POST["trenner"])?$_POST["trenner"]:",";
60 //echo "../users/$login.conf";
61 if (!file_exists("../users/$login.conf")) ende(3);
63 if (!file_exists("$file.csv")) ende(5);
67 if (!$db->chkcol($file)) ende(6);
69 $employee=chkUsr($login);
70 if (!$employee) ende(4);
72 $kunde_fld = array_keys($address);
74 $f=fopen("$file.csv","r");
75 $zeile=fgets($f,1200);
76 $infld=split($trenner,strtolower($zeile));
79 foreach ($infld as $fld) {
80 $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
81 if ($fld=="branche" && !$crm) { $in_fld[]=""; continue; };
82 if ($fld=="sw" && !$crm) { $in_fld[]=""; continue; };
85 //print_r($in_fld); echo "<br>";
88 $zeile=fgetcsv($f,1200,$trenner);
89 if ($ok) while (!feof($f)){
91 //echo "Arbeite an $m ";
95 $sql="insert into $file ";
99 foreach($zeile as $data) {
100 if (!in_array(trim($in_fld[$i]),$kunde_fld)) {
101 if ($in_fld[$i]=="anrede") { $anrede=addslashes(trim($data)); }
106 $data=mb_convert_encoding($data,"ISO-8859-15","auto");
107 //$data=htmlentities($data);
108 $data=addslashes($data);
109 if ($in_fld[$i]==$file."number") { // customernumber || vendornumber
110 if (empty($data) or !$data) {
114 $data=chkKdId($data);
117 } else if ($in_fld[$i]=="taxincluded"){
118 $data=strtolower(substr($data,0,1));
119 if ($data!="f" && $data!="t") $data="f";
120 } else if ($in_fld[$i]=="ustid"){
121 $data=strtr(" ","",$data);
122 } /*else if ($in_fld[$i]=="matchcode") {
126 if ($data==false or empty($data) or !$data) {
127 if (in_array($in_fld[$i],array("name"))) {
133 $keys.=$in_fld[$i].",";
134 if ($data==false or empty($data) or !$data) {
137 if ($in_fld[$i]=="contact"){
139 $vals.="'$anrede $data',";
144 $vals.="'".$data."',";
150 $keys.=$file."number,";
151 $vals.="'".getKdId()."',";
156 echo "<table border='1'>\n";
157 echo "<tr><th>".str_replace(",","</th><th>",substr($keys,1,-1))."</th></tr>\n";
160 $vals=str_replace("',","'</td><td>",substr($vals,9,-1));
161 echo "<tr><td>".str_replace("null,","null</td><td>",$vals)."</td></tr>\n";
162 //echo "Import $j<br>\n";
165 $sql.=$keys."taxzone_id,import)";
166 $sql.=$vals."0,$nun)";
167 $rc=$db->query($sql);
168 if (!$rc) echo "Fehler: ".$sql."<br>";
172 $vals=str_replace("',","'</td><td>",substr($vals,9,-1));
173 echo "<tr><td style=\"color:red\">".str_replace("null,","null</td><td style=\"color:red\">",$vals)."</td></tr>\n";
176 $zeile=fgetcsv($f,1200,$trenner);
179 if ($test) echo "</table>\n ##### = Neue Kunden-/Lieferantennummer\n<br>";
180 echo $j." $file importiert.\n";
184 <p class="listtop">Adressimport für die ERP<p>
186 <form name="import" method="post" enctype="multipart/form-data" action="addressB.php">
187 <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
188 <input type="hidden" name="login" value="<?= $login ?>">
190 <tr><td></td><td><input type="submit" name="ok" value="Hilfe"></td></tr>
191 <tr><td>Zieltabelle</td><td><input type="radio" name="ziel" value="customer" checked>customer <input type="radio" name="ziel" value="vendor">vendor</td></tr>
192 <tr><td>Trennzeichen</td><td><input type="text" size="2" maxlength="1" name="trenner" value=";"></td></tr>
193 <tr><td>Test</td><td><input type="checkbox" name="test" value="1">ja</td></tr>
194 <tr><td>Daten</td><td><input type="file" name="Datei"></td></tr>
195 <tr><td></td><td><input type="submit" name="ok" value="Import"></td></tr>