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));
78 //print_r($infld); echo "<br>";
81 foreach ($infld as $fld) {
82 $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
83 if ($fld=="branche" && !$crm) { $in_fld[]=""; continue; };
84 if ($fld=="sw" && !$crm) { $in_fld[]=""; continue; };
87 //print_r($in_fld); echo "<br>";
90 $zeile=fgetcsv($f,1200,$trenner);
91 if ($ok) while (!feof($f)){
93 //echo "Arbeite an $m ";
97 $sql="insert into $file ";
101 foreach($zeile as $data) {
102 if (!in_array(trim($in_fld[$i]),$kunde_fld)) {
103 if ($in_fld[$i]=="anrede") { $anrede=addslashes(trim($data)); }
108 //$data=htmlentities($data);
109 $data=addslashes($data);
110 if (trim($in_fld[$i])==$file."number") { // customernumber || vendornumber
111 if (empty($data) or !$data) {
115 $data=chkKdId($data);
118 } else if ($in_fld[$i]=="taxincluded"){
119 $data=strtolower(substr($data,0,1));
120 if ($data!="f" && $data!="t") $data="f";
121 } else if ($in_fld[$i]=="language") {
122 $data=strtolower(substr($data,0,2));
123 if (!in_array($data,array("de","en","fr"))) $data=false;
125 if ($in_fld[$i]=="matchcode") {
131 if ($data==false or empty($data) or !$data) {
132 if (in_array($in_fld[$i],array("name"))) {
136 $keys.=$in_fld[$i].",";
137 if ($data==false or empty($data) or !$data) {
138 if (in_array($in_fld[$i],array("name"))) {
144 if ($in_fld[$i]=="contact"){
146 $vals.="'$anrede $data',";
151 $vals.="'".$data."',";
157 $keys.=$file."number,";
158 $vals.="'".getKdId()."',";
163 echo "<table border='1'>\n";
164 echo "<tr><th>".str_replace(",","</th><th>",substr($keys,1,-1))."</th></tr>\n";
167 $vals=str_replace("',","'</td><td>",substr($vals,9,-1));
168 echo "<tr><td>".str_replace("null,","null</td><td>",$vals)."</td></tr>\n";
169 //echo "Import $j<br>\n";
172 $sql.=$keys."import)";
174 $rc=$db->query($sql);
175 if (!$rc) echo "Fehler: ".$vals."<br>";
179 $vals=str_replace("',","'</td><td>",substr($vals,9,-1));
180 echo "<tr><td style=\"color:red\">".str_replace("null,","null</td><td style=\"color:red\">",$vals)."</td></tr>\n";
183 $zeile=fgetcsv($f,1200,$trenner);
186 if ($test) echo "</table>\n ##### = Neue Kunden-/Lieferantennummer\n<br>";
187 echo $j." $file importiert.\n";
191 <p class="listtop">Adressimport für die ERP<p>
193 <form name="import" method="post" enctype="multipart/form-data" action="addressB.php">
194 <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
195 <input type="hidden" name="login" value="<?= $login ?>">
197 <tr><td></td><td><input type="submit" name="ok" value="Hilfe"></td></tr>
198 <tr><td>Zieltabelle</td><td><input type="radio" name="ziel" value="customer" checked>customer <input type="radio" name="ziel" value="vendor">vendor</td></tr>
199 <tr><td>Trennzeichen</td><td><input type="text" size="2" maxlength="1" name="trenner" value=";"></td></tr>
200 <tr><td>Test</td><td><input type="checkbox" name="test" value="1">ja</td></tr>
201 <tr><td>Daten</td><td><input type="file" name="Datei"></td></tr>
202 <tr><td></td><td><input type="submit" name="ok" value="Import"></td></tr>