Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / xtcom / erpexport.php
1 <?
2 /***************************************************************
3 * $Id: erpexport.php,v 1.1 2004/06/29 08:50:30 hli Exp $
4 *Author: Holger Lindemann
5 *Copyright: (c) 2004 Lx-System
6 *License: non free
7 *eMail: info@lx-system.de
8 *Version: 1.0.0
9 *ERP: Lx-Office ERP
10 ***************************************************************/
11 ?>
12 <html>
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">
16         <!--
17                 function xtcomm() {
18                         document.fld.PN.value="products_model"; document.fld.partnumber.checked=true;
19                         document.fld.BEZ.value="products_name"; document.fld.desctiption.checked=true;
20                         document.fld.GEWICHT.value="products_weight"; document.fld.weight.checked=true;
21                         document.fld.MWST.value="products_tax"; document.fld.rate.checked=true;
22                         document.fld.VK.value="products_price"; document.fld.sellprice.checked=true;
23                         document.fld.PG.value="categories_name"; document.fld.partsgroup.checked=true;
24                         document.fld.BESCHR.value="products_description"; document.fld.notes.checked=true;
25                         document.fld.LAGER.value="products_quantity"; 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="xtcomm";
31                 }
32         //-->
33         </script>
34 <body>
35
36 <?php
37 require_once "shoplib.php";
38
39 function artikel() {
40         $sql ="SELECT P.partnumber,P.description,P.unit,P.weight,t.rate,P.sellprice,P.listprice,P.priceupdate,";
41         $sql.="PG.partsgroup,P.notes,P.image,P.onhand,P.buchungsgruppen_id as bugru FROM ";
42         $sql.="chart c left join tax t on c.taxkey_id=t.taxkey, parts P left join partsgroup PG on ";
43         $sql.="PG.id=P.partsgroup_id left join buchungsgruppen B  on P.buchungsgruppen_id = B.id ";
44         $sql.="WHERE P.shop='t'  and c.id=B.income_accno_id_0";
45         $rs=getAll("erp",$sql,"artikel");
46         return $rs;
47 }
48
49 if ($_POST["export"]) {
50         $data=artikel();
51         $delim=($_POST["deli"])?$_POST["deli"]:",";
52         if (get_magic_quotes_gpc()) {
53                 $crln = stripslashes($_POST["crln"]);
54         }
55         $crln = str_replace('\\r', "\015", $crln);
56         $crln = str_replace('\\n', "\012", $crln);
57         $crln = str_replace('\\t', "\011", $crln);
58         $encl=$_POST["encl"];
59         $i=0;
60         $f=fopen($ERPdir,"w");
61         if ($_POST["partnumber"])       {$header.=$_POST["PN"].$delim; };
62         if ($_POST["desctiption"])      {$header.=$_POST["BEZ"].$delim; };
63         if ($_POST["unit"])             {$header.=$_POST["EINHEIT"].$delim; };
64         if ($_POST["onhand"])           {$header.=$_POST["LAGER"].$delim; };
65         if ($_POST["weight"])           {$header.=$_POST["GEWICHT"].$delim; };
66         if ($_POST["rate"])             {$header.=$_POST["MWST"].$delim; };
67         if ($_POST["sellprice"])        {$header.=$_POST["VK"].$delim; };
68         if ($_POST["listprice"])        {$header.=$_POST["EK"].$delim; };
69         if ($_POST["priceupdate"])      {$header.=$_POST["PDATE"].$delim; };
70         if ($_POST["partsgroup"])       {$header.=$_POST["PG"].$delim; };
71         if ($_POST["notes"])            {$header.=$_POST["BESCHR"].$delim; };
72         if ($_POST["image"])            {$header.=$_POST["IMAGE"].$delim; };
73         $header=substr($header,0,-1);
74 ?>
75 <table class="liste">
76 <!-- BEGIN Artikel -->
77 <?      $i=0;
78         $f=fopen($ERPdir,"w");
79         if ($_POST["head"]) fputs($f,$header.$crln);
80         foreach($data as $zeile) {
81                 $file=""; $html="";
82                 if ($_POST["shop"]=="pepper") {
83                         if (preg_match("/^\[.*\].*/",$zeile["partsgroup"])) { $PG=$zeile["partsgroup"]; }
84                         else { $PG="[".$zeile["partsgroup"]."]"; };
85                         $mwst=$zeile["rate"]*100;
86                 } else if ($_POST["shop"]=="oscomm") {
87                         $mwst=sprintf("%01.4f",($zeile["rate"]*100));
88                         $PG=$zeile["partsgroup"];
89                 } else {
90                         $PG=$zeile["partsgroup"];
91                         $mwst=$zeile["rate"]*100;
92                 };
93                 $LineCol = $bgcol[$i%2+1];
94                 if ($_POST["partnumber"])       {$file.=$encl.$zeile["partnumber"].$encl.$delim; $html.="<td>".$zeile["partnumber"]."</td>";};
95                 if ($_POST["desctiption"])      {$file.=$encl.strtr($zeile["description"],chr(13).chr(10),"  ").$encl.$delim; $html.="<td>".$zeile["description"]."</td>";};
96                 if ($_POST["unit"])                     {$file.=$encl.$zeile["unit"].$encl.$delim; $html.="<td>".$zeile["unit"]."</td>";};
97                 if ($_POST["onhand"])                   {$file.=$encl.$zeile["onhand"].$encl.$delim; $html.="<td>".$zeile["onhand"]."</td>";};
98                 if ($_POST["weight"])           {$file.=$encl.$zeile["weight"].$encl.$delim; $html.="<td>".$zeile["weight"]."</td>";};
99                 if ($_POST["rate"])                     {$file.=$encl.$mwst.$encl.$delim; $html.="<td>".$mwst."</td>";};
100                 if ($_POST["sellprice"])        {$file.=$encl.(sprintf("%02.2f",$zeile["sellprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["sellprice"]))."</td>";};
101                 if ($_POST["listprice"])        {$file.=$encl.(sprintf("%02.2f",$zeile["listprice"])).$encl.$delim; $html.="<td>".(sprintf("%02.2f",$zeile["listprice"]))."</td>";};
102                 if ($_POST["partsgroup"])       {$file.=$encl.$PG.$encl.$delim; $html.="<td>".$zeile["partsgroup"]."</td>";};
103                 if ($_POST["notes"])            {$file.=$encl.strtr($zeile["notes"],chr(13).chr(10),"  ").$encl.$delim; $html.="<td>".$zeile["notes"]."</td>";};
104                 if ($_POST["image"])            {$file.=$encl.$zeile["image"].$encl.$delim; $html.="<td>".$zeile["image"]."</td>";};
105                 $i++;
106                 fputs($f,substr($file,0,-1).$crln);
107                 if ($_POST["show"]) {
108 ?>
109         <tr  class="smal" onMouseover="this.bgColor='#FF0000';" onMouseout="this.bgColor='<?= $LineCol ?>';" bgcolor="<?= $LineCol ?>">
110                 <?= $html ?>
111         </tr>
112 <?              }
113         }
114 ?>
115 <!-- END Artikel -->
116 </table>
117 Anzahl der Artikel: <?= $i ?><br>
118 Export am : <?= date("d.m.Y : H:i") ?><br>
119 download <a href="tmp/shopartikel.csv">Exportfile</a><br><hr>
120 <?
121         fclose($f);
122 } // if ($export)
123 ?>
124 Export der Shopartikel aus Lx-ERP <br>
125 M&ouml;gliche Felder
126 <form name="fld" action="erpexport.php" method="post">
127 <input type="hidden" name="shop" value="">
128 <table>
129         <tr>
130                 <td><input type="checkbox" name="partnumber" value="1">Artikelnummer</td>
131                 <td><input type="checkbox" name="desctiption" value="1">Bezeichnung</td>
132                 <td><input type="checkbox" name="unit" value="1">Einheit</td>
133                 <td><input type="checkbox" name="weight" value="1">Gewicht</td>
134         </tr>
135         <tr>
136                 <td><input type="text" name="PN" size="23"></td>
137                 <td><input type="text" name="BEZ" size="23"></td>
138                 <td><input type="text" name="EINHEIT" size="23"></td>
139                 <td><input type="text" name="GEWICHT" size="23"></td>
140         </tr>
141         <tr><td colspan=5></td></tr>
142         <tr>
143                 <td><input type="checkbox" name="sellprice" value="1">Verkaufspreis</td>
144                 <td><input type="checkbox" name="listprice" value="1">Listenpreis</td>
145                 <td><input type="checkbox" name="onhand" value="1">Lagerbestand</td>
146                 <td><input type="checkbox" name="rate" value="1">MwSt</td>
147         </tr>
148         <tr>
149                 <td><input type="text" name="VK" size="23"></td>
150                 <td><input type="text" name="EK" size="23"></td>
151                 <td><input type="text" name="LAGER" size="23"></td>
152                 <td><input type="text" name="MWST" size="23"></td>
153         </tr>
154         <tr><td colspan=5></td></tr>
155         <tr>
156                 <td><input type="checkbox" name="partsgroup" value="1">Gruppe</td>
157                 <td><input type="checkbox" name="notes" value="1">Beschreibung</td>
158                 <td><input type="checkbox" name="image" value="1">Bild</td>
159                 <td><input type="checkbox" name="show" value="1" checked>HTML-Anzeige</td>
160         </tr>
161         <tr>
162                 <td><input type="text" name="PG" size="23"></td>
163                 <td><input type="text" name="BESCHR" size="23"></td>
164                 <td><input type="text" name="IMAGE" size="23"></td>
165                 <td></td>
166         </tr>
167         <tr>
168                 <td>Feldtrenner <input type="text" name="deli" size="2" value=","></td>
169                 <td>Feldumrahmung <input type="text" name="encl" size="2" value="&quot;"></td>
170                 <td>Zeilenende <input type="text" name="crln" size="2" value="\n"></td>
171                 <td><input type="checkbox" name="head" value="1" checked>Headline</td>
172         </tr>
173         <tr>
174                 <td colspan=5><input type="submit" name="export" value="Export"> <input type="button" name="xsc" value="xtCommerce" onClick="xtcomm()"></td>
175         </tr>
176 </table>
177 <a href="trans.php">zur&uuml;ck</a>
178 </form>
179 </body>
180 </html>