Benutzerdefinierte Variablen bei Ansprechpartnern über CSV importierbar machen.
[kivitendo-erp.git] / peppershop / ArtikelShopToErp.php
1 <?php
2
3 $debug = False;
4
5 $api = php_sapi_name();
6 if ( $api != "cli" ) {
7     echo "<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n</head>\n<body>\n";
8     @apache_setenv('no-gzip', 1);
9     @ini_set('zlib.output_compression', 0);
10     @ini_set('implicit_flush', 1);
11     $shopnr = $_GET["Shop"];
12     $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
13 } else {
14     if ( $argc > 1 ) {
15         $tmp = explode("=",trim($argv[1]));
16         if ( count($tmp) != 2 ) {
17              echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
18              exit (-1);
19          } else {
20               $shopnr = $tmp[1];
21          }
22     }
23 }
24
25 include_once("conf$shopnr.php");
26 include_once("error.php");
27 //Fehlerinstanz
28 $err = new error($api);
29
30 include_once("dblib.php");
31 include_once("pepper.php");
32 include_once("erplib.php");
33
34
35
36 //ERP-Instanz
37 $erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug);
38 if ($erpdb->db->connected_database_name == $ERPdbname) {
39     $erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID);
40 } else {
41     $err->out('Keine Verbindung zur ERP',true);
42     exit();
43 }
44
45 //Shop-Instanz
46 $shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
47 if ($shopdb->db->connected_database_name == $SHOPdbname) {
48      $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr);
49 } else {
50     $err->out('Keine Verbindung zum Shop',true);
51     exit();
52 }
53
54 $artikel = $shop->getAllArtikel();
55 $cnt = 0;
56 $errors = 0;
57 //Artikel die mehreren Warengruppen zugeordnet sind, werden nur einmal importiert.
58 //Es wird dann auch nur die erste Warengruppe angelegt.
59 if ( $api != 'cli' ) ob_start();
60
61 $err->out("Artikelimport von Shop $shopnr",true);
62
63 if ($artikel) foreach ($artikel as $row) {
64      $rc = $erp->chkPartnumber($row,true);
65      if ($rc) { 
66         $cnt++;
67      } else { 
68         $err->out('Fehler: '.$row['partnumber'],true);
69         $errors++;
70      }
71 }
72 $err->out('',true);
73 $err->out("$cnt Artikel geprüft bzw. übertragen, $errors Artikel nicht",true);
74 if ( $api != "cli" ) {
75     echo "</body>\n</html>\n";
76 }
77 ?>