2 <LINK REL="stylesheet" HREF="../css/lx-office-erp.css" TYPE="text/css" TITLE="Lx-Office stylesheet">
6 Lieferanschriftimport mit Browser nach Lx-Office ERP
10 Email: p.reetz@linet-services.de
11 Web: http://www.linet-services.de
15 $login=$_GET["login"];
17 $login=$_POST["login"];
20 require ("import_lib.php");
25 $login=$_POST["login"];
29 $shipto_fld = array_keys($shiptos);
35 echo "Abbruch: $nr\n";
36 echo "Aufruf: shiptoB.php [login customer|vendor] [test] | [felder]\n";
39 if ($_POST["ok"]=="Hilfe") {
40 echo "Importfelder:<br>";
41 echo "Feldname => Bedeutung<br>";
42 foreach($shiptos as $key=>$val) {
43 echo "$key => $val<br>";
50 $trenner=($_POST["trenner"])?$_POST["trenner"]:",";
52 if (!empty($_FILES["Datei"]["name"])) {
54 if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file."_shipto.csv")) {
56 echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")<br>";
58 } else if (is_file($_POST["ziel"]."_shipto.csv")) {
66 if (!file_exists($file."_shipto.csv")) ende(5);
68 if (!file_exists("../users/$login.conf")) ende(3);
71 $employee=chkUsr($login);
72 if (!$employee) ende(4);
74 if (!$db->chkcol($file)) ende(6);
76 $f=fopen($file."_shipto.csv","r");
77 $zeile=fgets($f,1000);
78 $infld=split($trenner,strtolower($zeile));
82 foreach ($infld as $fld) {
83 $fld = trim(strtr($fld,array("\""=>"","'"=>"")));
87 $zeile=fgetcsv($f,1000,$trenner);
93 $sql="insert into shipto ";
96 foreach($zeile as $data) {
98 if ($in_fld[$i]=="firma") {
99 $firma=addslashes(trim($data));
102 if (!in_array($in_fld[$i],$shipto_fld)) {
105 $data=addslashes(trim($data));
106 if ($in_fld[$i]=="trans_id" && $data) {
107 $data=chkKdId($data);
108 if ($data) $firma="";
109 if (!$id) $id = $data;
112 if ($in_fld[$i]==$file."number" && $data) {
113 $tmp=getFirma($data,$file);
115 if ($id<>$tmp) $id=$tmp;
118 $keys.=$in_fld[$i].",";
120 if ($data==false or empty($data) or !$data) {
123 if (in_array($in_fld[$i],array("cp_fax","cp_phone1","cp_phone2"))) {
125 } else if ($in_fld[$i]=="cp_country" && $data) {
128 if ($in_fld[$i]=="cp_name") $name=true;
129 $vals.="'".$data."',";
130 // bei jedem gefuellten Datenfeld erhoehen
135 // $zeile=fgetcsv($f,1000,$trenner);
139 $data=suchFirma($file,$firma);
141 $vals.=$data["trans_id"].",";
151 echo "<table border='1'>\n";
152 echo "<tr><th>".str_replace(",","</th><th>",substr($keys,1,-1))."</th></tr>\n";
155 $vals=str_replace("',","'</td><td>",substr($vals,9,-1));
156 echo "<tr><td>".str_replace("null,","null</td><td>",$vals)."</td></tr>\n";
159 $sql.=substr($keys,0,-1).")";
160 $sql.=substr($vals,0,-1).")";
161 $rc=$db->query($sql);
162 if (!$rc) echo "Fehler: ".$sql."\n";
166 $zeile=fgetcsv($f,1000,$trenner);
169 echo $j." $file importiert.\n";} else {
171 <p class="listtop">Lieferanschriftimport für die ERP</p>
172 <form name="import" method="post" enctype="multipart/form-data" action="shiptoB.php">
173 <input type="hidden" name="MAX_FILE_SIZE" value="300000">
174 <input type="hidden" name="login" value="<?= $login ?>">
176 <tr><td></td><td><input type="submit" name="ok" value="Hilfe"></td></tr>
177 <tr><td>Zieltabelle</td><td><input type="radio" name="ziel" value="customer" checked>customer <input type="radio" name="ziel" value="vendor">vendor</td></tr>
178 <tr><td>Trennzeichen</td><td><input type="text" size="2" maxlength="1" name="trenner" value=";"></td></tr>
179 <tr><td>Test</td><td><input type="checkbox" name="test" value="1">ja</td></tr>
180 <tr><td>Daten</td><td><input type="file" name="Datei"></td></tr>
181 <tr><td></td><td><input type="submit" name="ok" value="Import"></td></tr>