2 /***************************************************************
3 * $Id: erpexport.php 2006/02/06 13:50:30 hli Exp $
4 *Author: Holger Lindemann
5 *Copyright: (c) 2004 Lx-System
7 *eMail: info@lx-system.de
10 ***************************************************************/
13 <head><title>Lx-ERP Export der Shopartikel</title>
14 <link type="text/css" REL="stylesheet" HREF="css/main.css"></link>
15 <script language="JavaScript">
18 document.fld.PN.value="Artikel-Nr"; document.fld.partnumber.checked=true;
19 document.fld.BEZ.value="Name"; document.fld.desctiption.checked=true;
20 document.fld.GEWICHT.value="Gewicht"; document.fld.weight.checked=true;
21 document.fld.MWST.value="MwSt-Satz"; document.fld.rate.checked=true;
22 document.fld.VK.value="Preis"; document.fld.sellprice.checked=true;
23 document.fld.PG.value="Kategorien"; document.fld.partsgroup.checked=true;
24 document.fld.BESCHR.value="Beschreibung"; document.fld.notes.checked=true;
25 document.fld.PG.value="Lagerbestand"; document.fld.onhand.checked=true;
26 document.fld.encl.value="";
27 document.fld.deli.value=";";
28 document.fld.crln.value="\\n";
29 document.fld.head.checked=true;
30 document.fld.shop.value="pepper";
37 require_once "DB.php";
38 require_once "conf.php";
40 $db=DB::connect($ERPdns);
41 if (!$db) dbFehler("",$db->getDebugInfo());
42 if (DB::isError($db)) {
43 dbFehler("",$db->getDebugInfo());
44 die ($db->getDebugInfo());
46 /****************************************************
48 * in: sql,err = string
50 * Fehlermeldungen ausgeben
51 *****************************************************/
52 function dbFehler($sql,$err) {
55 echo "</td></tr></table><font color='red'>$sql : $err</font><br>";
58 function shopartikel() {
60 $sql ="SELECT P.partnumber,P.description,P.unit,P.weight,t.rate,P.sellprice,P.listprice,P.priceupdate,PG.partsgroup,P.notes,P.image FROM ";
61 $sql.="parts P left join partsgroup PG on PG.id=P.partsgroup_id ";
62 $sql.="left join chart c on c.id = P.income_accno_id ";
63 $sql.="left join tax T on T.taxkey=C.taxkey_id ";
64 $sql.="where shop = 't'";
65 $rs=$db->getAll($sql,DB_FETCHMODE_ASSOC);
68 if ($_POST["export"]) {
70 $delim=($_POST["deli"])?$_POST["deli"]:",";
71 if (get_magic_quotes_gpc()) {
72 $crln = stripslashes($_POST["crln"]);
74 $crln = str_replace('\\r', "\015", $crln);
75 $crln = str_replace('\\n', "\012", $crln);
76 $crln = str_replace('\\t', "\011", $crln);
79 $f=fopen($ERPdir,"w");
80 if ($_POST["partnumber"]) {$header.=$_POST["PN"].$delim; };
81 if ($_POST["desctiption"]) {$header.=$_POST["BEZ"].$delim; };
82 if ($_POST["unit"]) {$header.=$_POST["EINHEIT"].$delim; };
83 if ($_POST["weight"]) {$header.=$_POST["GEWICHT"].$delim; };
84 if ($_POST["onhand"]) {$header.=$_POST["LAGER"].$delim; };
85 if ($_POST["rate"]) {$header.=$_POST["MWST"].$delim; };
86 if ($_POST["sellprice"]) {$header.=$_POST["VK"].$delim; };
87 if ($_POST["listprice"]) {$header.=$_POST["EK"].$delim; };
88 if ($_POST["priceupdate"]) {$header.=$_POST["PDATE"].$delim; };
89 if ($_POST["partsgroup"]) {$header.=$_POST["PG"].$delim; };
90 if ($_POST["notes"]) {$header.=$_POST["BESCHR"].$delim; };
91 if ($_POST["image"]) {$header.=$_POST["IMAGE"].$delim; };
92 $header=substr($header,0,-1);
95 <!-- BEGIN Artikel -->
97 function downloadImage($image,$name) {
98 global $ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir, $maxSize, $iconSize;
99 $conn_id = ftp_connect($ERPftphost);
100 ftp_login($conn_id,$ERPftpuser,$ERPftppwd);
101 $src=$ERPimgdir."/".$image;
102 $typ=substr($image,strrpos($image,"."));
103 echo "tmp/".$name."_gr$typ $src";
104 $upload=ftp_get($conn_id,"tmp/".$name."_gr$typ","$src",FTP_BINARY);
106 if (!$upload) { echo "Ftp download war fehlerhaft!"; return false; };
107 echo "convert -resize $iconSize tmp/".$name."_gr$typ tmp/".$name."_kl$typ";
108 exec("convert -resize $iconSize tmp/".$name."_gr$typ tmp/".$name."_kl$typ",$aus,$rc);
109 print_r($aus); echo "!$rc!";
112 $f=fopen($ERPdir,"w");
113 if ($_POST["head"]) fputs($f,$header.$crln);
114 foreach($data as $zeile) {
116 if ($_POST["shop"]=="pepper") {
117 if (preg_match("/^\[.*\].*/",$zeile["partsgroup"])) { $PG=$zeile["partsgroup"]; }
118 else { $PG="[".$zeile["partsgroup"]."]"; };
119 $mwst=$zeile["rate"]*100;
120 } else if ($_POST["shop"]=="oscomm") {
121 $mwst=sprintf("%01.4f",($zeile["rate"]*100));
122 $PG=$zeile["partsgroup"];
124 $PG=$zeile["partsgroup"];
125 $mwst=$zeile["rate"]*100;
127 $LineCol = $bgcol[$i%2+1];
128 if ($_POST["partnumber"]) {$file.=$encl.$zeile["partnumber"].$encl.$delim; $html.="<td>".$zeile["partnumber"]."</td>";};
129 if ($_POST["desctiption"]) {$file.=$encl.strtr($zeile["description"],chr(13).chr(10)," ").$encl.$delim; $html.="<td>".$zeile["description"]."</td>";};
130 if ($_POST["unit"]) {$file.=$encl.$zeile["unit"].$encl.$delim; $html.="<td>".$zeile["unit"]."</td>";};
131 if ($_POST["onhand"]) {$file.=$encl.$zeile["onhand"].$encl.$delim; $html.="<td>".$zeile["onhand"]."</td>";};
132 if ($_POST["weight"]) {$file.=$encl.$zeile["weight"].$encl.$delim; $html.="<td>".$zeile["weight"]."</td>";};
133 if ($_POST["rate"]) {$file.=$encl.$mwst.$encl.$delim; $html.="<td>".$mwst."</td>";};
134 if ($_POST["sellprice"]) {$file.=$encl.(sprintf("%02.2f",$zeile["sellprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["sellprice"]))."</td>";};
135 if ($_POST["listprice"]) {$file.=$encl.(sprintf("%02.2f",$zeile["listprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["listprice"]))."</td>";};
136 if ($_POST["priceupdate"]) {$file.=$encl.$zeile["priceupdate"].$encl.$delim; $html.="<td>".$zeile["priceupdate"]."</td>";};
137 if ($_POST["partsgroup"]) {$file.=$encl.$PG.$encl.$delim; $html.="<td>".$zeile["partsgroup"]."</td>";};
138 if ($_POST["notes"]) {$file.=$encl.strtr($zeile["notes"],chr(13).chr(10)," ").$encl.$delim; $html.="<td>".$zeile["notes"]."</td>";};
139 if ($_POST["image"]) {$file.=$encl.$zeile["image"].$encl.$delim; $html.="<td>".$zeile["image"]."</td>";};
141 fputs($f,substr($file,0,-1).$crln);
142 if ($zeile["image"] && $_POST["image"]) { downloadImage($zeile["image"],$zeile["partnumber"]); }
143 if ($_POST["show"]) {
145 <tr class="smal" onMouseover="this.bgColor='#FF0000';" onMouseout="this.bgColor='<?= $LineCol ?>';" bgcolor="<?= $LineCol ?>">
153 Anzahl der Artikel: <?= $i ?><br>
154 Export am : <?= date("d.m.Y : H:i") ?><br>
155 download <a href="tmp/shopartikel.csv">Exportfile</a><br><hr>
160 Export der Shopartikel aus Lx-ERP <br>
162 <form name="fld" action="erpexport.php" method="post">
163 <input type="hidden" name="shop" value="">
166 <td><input type="checkbox" name="partnumber" value="1">Artikelnummer</td>
167 <td><input type="checkbox" name="desctiption" value="1">Bezeichnung</td>
168 <td><input type="checkbox" name="unit" value="1">Einheit</td>
169 <td><input type="checkbox" name="weight" value="1">Gewicht</td>
172 <td><input type="text" name="PN" size="23"></td>
173 <td><input type="text" name="BEZ" size="23"></td>
174 <td><input type="text" name="EINHEIT" size="23"></td>
175 <td><input type="text" name="GEWICHT" size="23"></td>
177 <tr><td colspan=5></td></tr>
179 <td><input type="checkbox" name="sellprice" value="1">Verkaufspreis</td>
180 <td><input type="checkbox" name="listprice" value="1">Listenpreis</td>
181 <td><input type="checkbox" name="onhand" value="1">Lagerbestand</td>
182 <td><input type="checkbox" name="rate" value="1">MwSt</td>
185 <td><input type="text" name="VK" size="23"></td>
186 <td><input type="text" name="EK" size="23"></td>
187 <td><input type="text" name="LAGER" size="23"></td>
188 <td><input type="text" name="MWST" size="23"></td>
190 <tr><td colspan=5></td></tr>
192 <td><input type="checkbox" name="partsgroup" value="1">Gruppe</td>
193 <td><input type="checkbox" name="notes" value="1">Beschreibung</td>
194 <td><input type="checkbox" name="image" value="1">Bild</td>
195 <td><input type="checkbox" name="show" value="1" checked>HTML-Anzeige</td>
198 <td><input type="text" name="PG" size="23"></td>
199 <td><input type="text" name="BESCHR" size="23"></td>
200 <td><input type="text" name="IMAGE" size="23"></td>
204 <td>Feldtrenner <input type="text" name="deli" size="2" value=","></td>
205 <td>Feldumrahmung <input type="text" name="encl" size="2" value="""></td>
206 <td>Zeilenende <input type="text" name="crln" size="2" value="\n"></td>
207 <td><input type="checkbox" name="head" value="1" checked>Headline</td>
210 <td colspan=5><input type="submit" name="export" value="Export"> <input type="button" name="pep" value="Peppershop" onClick="pepper()"> <input type="button" name="osc" value="osCommerce" onClick="oscomm()"></td>
213 <a href="trans.php">zurück</a>