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 echo "Abbruch: $nr\n";
19 if ($_POST["ok"]=="Hilfe") {
20 echo "Importfelder:<br>";
21 echo "Feldname => Bedeutung<br>";
22 foreach($shiptos as $key=>$val) {
23 echo "$key => $val<br>";
28 if (!$_SESSION["db"]) {
29 $conffile="../config/authentication.pl";
30 if (!is_file($conffile)) {
34 require ("import_lib.php");
36 if (!anmelden()) ende(5);
39 $db=$_SESSION["db"]; //new myDB($login);
44 if ($_POST["ok"] == "Import") {
47 $shipto_fld = array_keys($shiptos);
55 $trenner=($_POST["trenner"])?$_POST["trenner"]:",";
57 if (!empty($_FILES["Datei"]["name"])) {
59 if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$file."_shipto.csv")) {
61 echo "Upload von ".$_FILES["Datei"]["name"]." fehlerhaft. (".$_FILES["Datei"]["error"].")<br>";
63 } else if (is_file($_POST["ziel"]."_shipto.csv")) {
70 if (!file_exists($file."_shipto.csv")) ende(5);
72 $employee=chkUsr($_SESSION["employee"]);
73 if (!$employee) ende(4);
75 if (!$db->chkcol($file)) ende(6);
77 $f=fopen($file."_shipto.csv","r");
78 $zeile=fgetcsv($f,1000,$trenner);
81 foreach ($zeile as $fld) {
82 $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
86 $prenumber=$_POST["prenumber"];
87 $zeile=fgetcsv($f,1000,$trenner);
94 $sql="insert into shipto ";
97 foreach($zeile as $data) {
99 if (!in_array($in_fld[$i],$shipto_fld)) {
102 $data=addslashes(trim($data));
103 if ($in_fld[$i]=="trans_id" && $data) {
104 $data=chkKdId($data);
105 if (!$id) $id = $data;
107 } else if ($in_fld[$i]=="trans_id") {
110 if ($in_fld[$i]==$file."number" && $data) {
111 $tmp=getFirma($data,$file);
112 if ($id<>$tmp) $id=$tmp;
114 } else if ($in_fld[$i]==$file."number") {
117 if ($in_fld[$i]=="firma") {
119 $data=suchFirma($file,$firma);
121 $id=$data["cp_cv_id"];
125 $keys.=$in_fld[$i].",";
127 if ($data==false or empty($data) or !$data) {
130 if (in_array($in_fld[$i],array("cp_fax","cp_phone1","cp_phone2"))) {
131 $data=$prenumber.$data;
132 } else if ($in_fld[$i]=="cp_country" && $data) {
135 if ($in_fld[$i]=="cp_name") $name=true;
136 $vals.="'".$data."',";
137 // bei jedem gefuellten Datenfeld erhoehen
142 // $zeile=fgetcsv($f,1000,$trenner);
145 if ($keys<>"(" && $id) {
147 $keys.="trans_id,module";
150 echo "<table border='1'>\n";
151 echo "<tr><th>".str_replace(",","</th><th>",substr($keys,1,-1))."</th></tr>\n";
154 $vals=str_replace("',","'</td><td>",$vals);
155 echo "<tr><td>".str_replace("null,","null</td><td>",$vals)."</td></tr>\n";
160 $rc=$db->query($sql);
161 if (!$rc) echo "Fehler: ".$sql."\n";
168 $zeile=fgetcsv($f,1000,$trenner);
171 echo $j." $file importiert.\n";} else {
173 <p class="listtop">Lieferanschriftimport für die ERP</p>
174 <form name="import" method="post" enctype="multipart/form-data" action="shiptoB.php">
175 <input type="hidden" name="MAX_FILE_SIZE" value="300000">
177 <tr><td></td><td><input type="submit" name="ok" value="Hilfe"></td></tr>
178 <tr><td>Zieltabelle</td><td><input type="radio" name="ziel" value="customer" checked>customer <input type="radio" name="ziel" value="vendor">vendor</td></tr>
179 <tr><td>Trennzeichen</td><td><input type="text" size="2" maxlength="1" name="trenner" value=";"></td></tr>
180 <tr><td>Telefonvorwahl</td><td><input type="text" size="4" maxlength="10" name="prenumber" value=""></td></tr>
181 <tr><td>Test</td><td><input type="checkbox" name="test" value="1">ja</td></tr>
182 <tr><td>Daten</td><td><input type="file" name="Datei"></td></tr>
183 <tr><td></td><td><input type="submit" name="ok" value="Import"></td></tr>