Revision b90f08dc
Von Holger Lindemann vor fast 12 Jahren hinzugefügt
peppershop/ArtikelErpToShop.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 |
$p = array('shopnr','nofiles'); |
|
15 |
if ( $argc > 1 ) { |
|
16 |
for( $i=1; $i<count($argv); $i++) { |
|
17 |
$tmp = explode("=",trim($argv[$i])); |
|
18 |
if ( count($tmp) < 2 ) { |
|
19 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
20 |
exit (-1); |
|
21 |
}; |
|
22 |
if ( ! in_array(strtolower($tmp[0]),$p) ) { |
|
23 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
24 |
exit (-1); |
|
25 |
}; |
|
26 |
${$tmp[0]} = trim($tmp[1]); |
|
27 |
} |
|
28 |
} else { |
|
29 |
$shopnr=false; |
|
30 |
$nofiles=false; |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
include_once("conf$shopnr.php"); |
|
35 |
include_once("error.php"); |
|
36 |
//Fehlerinstanz |
|
37 |
$err = new error($api); |
|
38 |
|
|
39 |
include_once("dblib.php"); |
|
40 |
include_once("pepper.php"); |
|
41 |
include_once("erplib.php"); |
|
42 |
include_once("Picture.php"); |
|
43 |
|
|
44 |
|
|
45 |
//Bilder |
|
46 |
$pict = new picture($ERPftphost,$ERPftpuser,$ERPftppwd,$ERPimgdir,$SHOPftphost,$SHOPftpuser,$SHOPftppwd,$SHOPimgdir,$err); |
|
47 |
//$pict->original = false; |
|
48 |
|
|
49 |
//ERP-Instanz |
|
50 |
$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug); |
|
51 |
if ($erpdb->db->connected_database_name == $ERPdbname) { |
|
52 |
$erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID); |
|
53 |
} else { |
|
54 |
$err->out('Keine Verbindung zur ERP',true); |
|
55 |
exit(); |
|
56 |
} |
|
57 |
//Shop-Instanz |
|
58 |
$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug); |
|
59 |
|
|
60 |
if ($shopdb->db->connected_database_name == $SHOPdbname) { |
|
61 |
$shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr,$pict,$nopic,$nopicerr,$nofiles); |
|
62 |
} else { |
|
63 |
$err->out('Keine Verbindung zum Shop',true); |
|
64 |
exit(); |
|
65 |
} |
|
66 |
$artikel = $erp->getParts($pricegroup); |
|
67 |
$lang = $shop->getLang("de"); |
|
68 |
$cnt = 0; |
|
69 |
$errors = 0; |
|
70 |
|
|
71 |
if ( $api != 'cli' ) ob_start(); |
|
72 |
|
|
73 |
$err->out("Artikelexport für Shop $shopnr",true); |
|
74 |
|
|
75 |
if ($artikel) foreach ($artikel as $row) { |
|
76 |
$rc = $shop->saveArtikel($row,"de"); |
|
77 |
if ($rc) { |
|
78 |
$cnt++; |
|
79 |
if ( $cnt % 10 == 0 ) $err->out("."); |
|
80 |
} else { |
|
81 |
$errors++; |
|
82 |
} |
|
83 |
} |
|
84 |
$err->out('',true); |
|
85 |
$err->out("$cnt Artikel übertragen, $errors Artikel nicht",true); |
|
86 |
if ( $api != "cli" ) { |
|
87 |
echo "</body>\n</html>\n"; |
|
88 |
} |
|
89 |
?> |
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 |
$p = array('shopnr','nofiles'); |
|
15 |
if ( $argc > 1 ) { |
|
16 |
for( $i=1; $i<count($argv); $i++) { |
|
17 |
$tmp = explode("=",trim($argv[$i])); |
|
18 |
if ( count($tmp) < 2 ) { |
|
19 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
20 |
exit (-1); |
|
21 |
}; |
|
22 |
if ( ! in_array(strtolower($tmp[0]),$p) ) { |
|
23 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
24 |
exit (-1); |
|
25 |
}; |
|
26 |
${$tmp[0]} = trim($tmp[1]); |
|
27 |
} |
|
28 |
} else { |
|
29 |
$shopnr=false; |
|
30 |
$nofiles=false; |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
include_once("conf$shopnr.php"); |
|
35 |
include_once("error.php"); |
|
36 |
//Fehlerinstanz |
|
37 |
$err = new error($api); |
|
38 |
|
|
39 |
include_once("dblib.php"); |
|
40 |
include_once("pepper.php"); |
|
41 |
include_once("erplib.php"); |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
//ERP-Instanz |
|
46 |
$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug); |
|
47 |
if ($erpdb->db->connected_database_name == $ERPdbname) { |
|
48 |
$erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID); |
|
49 |
} else { |
|
50 |
$err->out('Keine Verbindung zur ERP',true); |
|
51 |
exit(); |
|
52 |
} |
|
53 |
|
|
54 |
//Shop-Instanz |
|
55 |
$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug); |
|
56 |
if ($shopdb->db->connected_database_name == $SHOPdbname) { |
|
57 |
$shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr); |
|
58 |
} else { |
|
59 |
$err->out('Keine Verbindung zum Shop',true); |
|
60 |
exit(); |
|
61 |
} |
|
62 |
|
|
63 |
$artikel = $shop->getAllArtikel(); |
|
64 |
$cnt = 0; |
|
65 |
$errors = 0; |
|
66 |
//Artikel die mehreren Warengruppen zugeordnet sind, werden nur einmal importiert. |
|
67 |
//Es wird dann auch nur die erste Warengruppe angelegt. |
|
68 |
if ( $api != 'cli' ) ob_start(); |
|
69 |
|
|
70 |
$err->out("Artikelimport von Shop $shopnr",true); |
|
71 |
|
|
72 |
if ($artikel) foreach ($artikel as $row) { |
|
73 |
$rc = $erp->chkPartnumber($row,true); |
|
74 |
if ($rc) { |
|
75 |
$cnt++; |
|
76 |
} else { |
|
77 |
$err->out('Fehler: '.$row['partnumber'],true); |
|
78 |
$errors++; |
|
79 |
} |
|
80 |
} |
|
81 |
$err->out('',true); |
|
82 |
$err->out("$cnt Artikel geprüft bzw. übertragen, $errors Artikel nicht",true); |
|
83 |
if ( $api != "cli" ) { |
|
84 |
echo "</body>\n</html>\n"; |
|
85 |
} |
|
86 |
?> |
peppershop/BestellungShopToErp.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 |
$p = array('shopnr','nofiles'); |
|
15 |
if ( $argc > 1 ) { |
|
16 |
for( $i=1; $i<count($argv); $i++) { |
|
17 |
$tmp = explode("=",trim($argv[$i])); |
|
18 |
if ( count($tmp) < 2 ) { |
|
19 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
20 |
exit (-1); |
|
21 |
}; |
|
22 |
if ( ! in_array(strtolower($tmp[0]),$p) ) { |
|
23 |
echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n"; |
|
24 |
exit (-1); |
|
25 |
}; |
|
26 |
${$tmp[0]} = trim($tmp[1]); |
|
27 |
} |
|
28 |
} else { |
|
29 |
$shopnr=false; |
|
30 |
$nofiles=false; |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
include_once("conf$shopnr.php"); |
|
35 |
include_once("error.php"); |
|
36 |
//Fehlerinstanz |
|
37 |
$err = new error($api); |
|
38 |
|
|
39 |
include_once("dblib.php"); |
|
40 |
include_once("pepper.php"); |
|
41 |
include_once("erplib.php"); |
|
42 |
|
|
43 |
$err->out("Shop $shopnr, Bestellimport",true); |
|
44 |
|
|
45 |
//ERP-Instanz |
|
46 |
$erpdb = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug); |
|
47 |
if ($erpdb->db->connected_database_name == $ERPdbname) { |
|
48 |
$erp = new erp($erpdb,$err,$divStd,$divVerm,$auftrnr,$kdnum,$preA,$preK,$invbrne,$mwstS,$OEinsPart,$lager,$pricegroup,$ERPusrID); |
|
49 |
} else { |
|
50 |
$err->out('Keine Verbindung zur ERP',true); |
|
51 |
exit(); |
|
52 |
} |
|
53 |
|
|
54 |
//Shop-Instanz |
|
55 |
$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug); |
|
56 |
if ($shopdb->db->connected_database_name == $SHOPdbname) { |
|
57 |
$shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr); |
|
58 |
//echo "<pre>"; print_r($shopdb->db); print_r($shopnr); echo "</pre>"; |
|
59 |
} else { |
|
60 |
$err->out('Keine Verbindung zum Shop',true); |
|
61 |
exit(); |
|
62 |
} |
|
63 |
|
|
64 |
$bestellungen = $shop->getBestellung($ERPusrID); |
|
65 |
//print_r($bestellungen); exit(1); |
|
66 |
$cnt = 0; |
|
67 |
$errors = 0; |
|
68 |
|
|
69 |
$err->out("Bestellimport vom Shop $shopnr",true); |
|
70 |
|
|
71 |
if ($bestellungen) foreach ($bestellungen as $row) { |
|
72 |
$rc = $erp->mkAuftrag($row,$shopnr,$longtxt); |
|
73 |
if ($rc>0) { |
|
74 |
$rc = $shop->setKundenNr($row['customer']['shopid'],$rc); |
|
75 |
if ($rc>0) { |
|
76 |
$shop->setAbgeholt($row['cusordnumber']); |
|
77 |
$cnt++; |
|
78 |
$err->out("ok",true); |
|
79 |
} else { |
|
80 |
$errors++; |
|
81 |
$err->out("Fehler setKdNr ".$row['customer']['shopid'],true); |
|
82 |
} |
|
83 |
} else if ($rc == -1) { |
|
84 |
$errors++; |
|
85 |
$err->out("Fehler mkAuftrag ".$row['cusordnumber'],true); |
|
86 |
} else { |
|
87 |
$err->out("Fehler Kunde zuordnen ".$row['customer']['shopid'].":".$row['cusordnumber'],true); |
|
88 |
$errors++; |
|
89 |
} |
|
90 |
} |
|
91 |
$err->out('Von '.count($bestellungen)." Bestellungen $cnt übertragen, $errors nicht",true); |
|
92 |
if ( $api != "cli" ) { |
|
93 |
echo "<br /><a href='../oe.pl?vc=customer&type=sales_order&nextsub=orders&action=Weiter&open=1¬delivered=1&delivered=1&l_ordnumber=Y&l_transdate=Y&l_reqdate=1&l_name=Y&l_employee=Y&l_amount=Y'>Auftragsliste</a>"; |
|
94 |
echo "</body>\n</html>\n"; |
|
95 |
} |
|
96 |
|
|
97 |
?> |
peppershop/LiesMich.txt | ||
---|---|---|
1 |
Varianten können in LxO eigene Artikelnummern haben. |
|
2 |
Die Artikelnummer wird dann automatisch ergänzt um "-" und die Variarions-ID. |
|
3 |
Aus "A1001" wird z.B. "A1001-1" für die erste (Standard) Variante. |
|
4 |
Variations-IDs MÜSSEN!! Lückenlos bei 1 beginnen, da sonst der Shop ins Schleudern kommt!!!!! |
|
5 |
|
|
6 |
Preise werden berechnet: Grundpreis + Preis für die Variante |
|
7 |
Text wird ergänzt: Standardtext + ", Variantengruppe: Variante" |
|
8 |
|
|
9 |
Ein beschreibbares Verzeichnis "tmp" wird als Unterverzeichnis erwartet. |
|
10 |
z.B.: |
|
11 |
ln -s /tmp |
|
12 |
|
|
13 |
Wenn ein Platzhalterbild eingesetzt werden soll, so muß das Bild zuerst auf |
|
14 |
den Shopserver übertragen werden. |
|
15 |
<bildname>_gr.jpg und <bildname>_kl.jpg |
|
16 |
|
|
17 |
Dann den Namen <bildname> in der Maske eintragen. Man kann bestimmen, ob |
|
18 |
das Bild immer genommen wird, wenn kein Bild angegeben wird oder nur wenn |
|
19 |
der Upload schief gegangen ist. |
|
20 |
|
|
21 |
Artikelexport (Lx -> Shop) kann ohne Bilderupload durchgeführt werden. |
|
22 |
Spart Bandbreite und Zeit, wenn nur Updates gemacht werden. |
|
23 |
Parameterübergabe: nofiles=1 |
|
24 |
[Shop--Warenexport] |
|
25 |
module=shop/ArtikelErpToShop.php |
|
26 |
nofiles=1 |
|
27 |
|
|
28 |
Shop ist Mehrshopfähig. Shopnummer muß beim Aufruf übergeben werden: |
|
29 |
Shop=1 |
|
30 |
|
|
31 |
Die Im-/Exportmodule lassen sich auch auf der Konsole oder per Cron-Job aufrufen: |
|
32 |
|
|
33 |
php ArtikelShopToErp.php shop=1 > /tmp/export.log |
peppershop/Picture.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
class picture { |
|
5 |
|
|
6 |
var $smallwidth = 150; |
|
7 |
var $bigwidth = 800; |
|
8 |
var $original = true; |
|
9 |
var $err = false; |
|
10 |
|
|
11 |
function picture($ERPhost,$ERPuser,$ERPpass,$ERPimgdir,$SHOPhost,$SHOPuser,$SHOPpass,$SHOPimgdir,$err) { |
|
12 |
$this->ERPftphost = $ERPhost; |
|
13 |
$this->ERPftpuser = $ERPuser; |
|
14 |
$this->ERPftppwd = $ERPpass; |
|
15 |
$this->ERPimgdir = $ERPimgdir; |
|
16 |
$this->SHOPftphost = $SHOPhost; |
|
17 |
$this->SHOPftpuser = $SHOPuser; |
|
18 |
$this->SHOPftppwd = $SHOPpass; |
|
19 |
$this->SHOPimgdir = $SHOPimgdir; |
|
20 |
$this->err = $err; |
|
21 |
} |
|
22 |
|
|
23 |
function copyImage($id,$image,$typ) { |
|
24 |
if ( !$this->fromERP($image) ) return false; |
|
25 |
if ( !$this->mkbilder() ) return false; |
|
26 |
return $this->toShop($id,$typ); |
|
27 |
} |
|
28 |
|
|
29 |
function mkbilder() { |
|
30 |
if ( !class_exists("Imagick") ) { $this->err->out("Imagick-Extention nicht installiert",true); return false; }; |
|
31 |
$handle = new Imagick(); |
|
32 |
if ( !$handle->readImage("./tmp/tmp.file_org") ) return false; |
|
33 |
$d = $handle->getImageGeometry(); |
|
34 |
if ( $d["width"]<$d["height"] ) { |
|
35 |
$faktor = $d["height"]/$d["width"]; |
|
36 |
} else { |
|
37 |
$faktor = $d["width"]/$d["height"]; |
|
38 |
} |
|
39 |
$smallheight = floor($this->smallwidth*$faktor); |
|
40 |
$handle->thumbnailImage($this->smallwidth, $smallheight, true); |
|
41 |
$rc = $handle->writeImage( "./tmp/tmp.file_small"); |
|
42 |
if ( !$this->original ) { |
|
43 |
$handle->readImage("./tmp/tmp.file_org"); |
|
44 |
$bigheight = floor($this->bigwidth * $faktor); |
|
45 |
$handle->thumbnailImage( $this->bigwidth, $bigheight,true); |
|
46 |
return $handle->writeImage( "./tmp/tmp.file_org"); |
|
47 |
} |
|
48 |
return $rc; |
|
49 |
} |
|
50 |
|
|
51 |
function fromERP($image) { |
|
52 |
if ( $this->ERPftphost == 'localhost' ) { |
|
53 |
exec("cp $this->ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2); |
|
54 |
if ( $rc2>0 ) { $this->err->out("[Downloadfehler: $image]",true); return false; }; |
|
55 |
} else { |
|
56 |
$conn_id = ftp_connect($this->ERPftphost); |
|
57 |
$rc = @ftp_login($conn_id,$this->ERPftpuser,$this->ERPftppwd); |
|
58 |
$src = $this->ERPimgdir."/".$image; |
|
59 |
$upload = @ftp_get($conn_id,"tmp/tmp.file_org","$src",FTP_BINARY); |
|
60 |
if ( !$upload ) { $this->err->out("[Ftp Downloadfehler! $image]",true); return false; }; |
|
61 |
ftp_quit($conn_id); |
|
62 |
} |
|
63 |
$this->image = $image; |
|
64 |
return true; |
|
65 |
} |
|
66 |
|
|
67 |
function toShop($id,$typ) { |
|
68 |
$grpic = $id."_gr.".$typ; |
|
69 |
$klpic = $id."_kl.".$typ; |
|
70 |
if ( $this->SHOPftphost == 'localhost' ) { |
|
71 |
exec("cp ./tmp/tmp.file_org $this->SHOPimgdir/$grpic",$aus,$rc1); |
|
72 |
exec("cp ./tmp/tmp.file_small $this->SHOPimgdir/$klpic",$aus,$rc2); |
|
73 |
if ( $rc1>0 || $rc2>0 ) { $this->err->out("[Uploadfehler: $this->image / $grpic]",true); return false; }; |
|
74 |
} else { |
|
75 |
$conn_id = ftp_connect($this->SHOPftphost); |
|
76 |
@ftp_login($conn_id,$this->SHOPftpuser,$this->SHOPftppwd); |
|
77 |
@ftp_chdir($conn_id,$this->SHOPimgdir); |
|
78 |
$upload = @ftp_put($conn_id,$this->SHOPimgdir."/$grpic","tmp/tmp.file_org",FTP_BINARY); |
|
79 |
if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! $grpic]",true); return false; }; |
|
80 |
$upload = @ftp_put($conn_id,$this->SHOPimgdir."/$klpic","tmp/tmp.file_small",FTP_BINARY); |
|
81 |
if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! $klpic]",true); return false; }; |
|
82 |
@ftp_quit($conn_id); |
|
83 |
} |
|
84 |
return true; |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
} |
|
89 |
?> |
peppershop/conf.php | ||
---|---|---|
1 |
<?php |
|
2 |
// Verbindung zur ERP-db |
|
3 |
$ERPuser='lxoffice'; |
|
4 |
$ERPpass='lxgeheim'; |
|
5 |
$ERPhost='localhost'; |
|
6 |
$ERPdbname='demo'; |
|
7 |
$codeLX='UTF-8'; |
|
8 |
$mwstLX='1'; |
|
9 |
$ERPusrName='demo'; |
|
10 |
$ERPusrID=''; |
|
11 |
$ERPimgdir='/var/www/lx-office-erp'; |
|
12 |
$maxSize=''; |
|
13 |
$ERPftphost='localhost'; |
|
14 |
$ERPftpuser='pepper'; |
|
15 |
$ERPftppwd='pepper'; |
|
16 |
//Verbindung zur osCommerce-db |
|
17 |
$SHOPuser='pepper'; |
|
18 |
$SHOPpass='sehrgeheim'; |
|
19 |
$SHOPhost='localhost'; |
|
20 |
$SHOPdbname='Pepper'; |
|
21 |
$codeS='UTF-8'; |
|
22 |
$mwstS='1'; |
|
23 |
$SHOPimgdir='/var/www/Pepper/shop/ProdukteBilder'; |
|
24 |
$SHOPftphost='localhost'; |
|
25 |
$SHOPftpuser='pepper'; |
|
26 |
$SHOPftppwd='pepper'; |
|
27 |
$nopic='nopic'; |
|
28 |
$nopicerr='1'; |
|
29 |
$divStd["ID"]=''; |
|
30 |
$divStd["NR"]='divStd'; |
|
31 |
$divStd["Unit"]=''; |
|
32 |
$divStd["TXT"]=''; |
|
33 |
$divStd["BUGRU"]=''; |
|
34 |
$divStd["TAX"]=''; |
|
35 |
$divVerm["ID"]=''; |
|
36 |
$divVerm["NR"]='divVerm'; |
|
37 |
$divVerm["Unit"]=''; |
|
38 |
$divVerm["TXT"]=''; |
|
39 |
$divVerm["BUGRU"]=''; |
|
40 |
$divVerm["TAX"]=''; |
|
41 |
$versandS["ID"]=''; |
|
42 |
$versandS["NR"]='divStd'; |
|
43 |
$versandS["Unit"]=''; |
|
44 |
$versandS["TXT"]='Versandkosten'; |
|
45 |
$versandS["BUGRU"]=''; |
|
46 |
$versandS["TAX"]=''; |
|
47 |
$versandV["ID"]=''; |
|
48 |
$versandV["NR"]='divVerm'; |
|
49 |
$versandV["Unit"]=''; |
|
50 |
$versandV["TXT"]='Versandkosten'; |
|
51 |
$versandV["BUGRU"]=''; |
|
52 |
$versandV["TAX"]=''; |
|
53 |
$minder["ID"]=''; |
|
54 |
$minder["NR"]='divStd'; |
|
55 |
$minder["Unit"]=''; |
|
56 |
$minder["TXT"]='Mindermengenzuschlag'; |
|
57 |
$minder["BUGRU"]=''; |
|
58 |
$minder["TAX"]=''; |
|
59 |
$nachn["ID"]=''; |
|
60 |
$nachn["NR"]=''; |
|
61 |
$nachn["Unit"]=''; |
|
62 |
$nachn["TXT"]=''; |
|
63 |
$nachn["BUGRU"]=''; |
|
64 |
$nachn["TAX"]=''; |
|
65 |
$treuh["ID"]=''; |
|
66 |
$treuh["NR"]=''; |
|
67 |
$treuh["Unit"]=''; |
|
68 |
$treuh["TXT"]='Treuhandkosten'; |
|
69 |
$treuh["BUGRU"]=''; |
|
70 |
$treuh["TAX"]=''; |
|
71 |
$paypal["ID"]=''; |
|
72 |
$paypal["NR"]='divStd'; |
|
73 |
$paypal["Unit"]=''; |
|
74 |
$paypal["TXT"]='Paypalkosten'; |
|
75 |
$paypal["BUGRU"]=''; |
|
76 |
$paypal["TAX"]=''; |
|
77 |
$bgcol[1]='#ddddff'; |
|
78 |
$bgcol[2]='#ddffdd'; |
|
79 |
$preA='G_'; |
|
80 |
$preK=''; |
|
81 |
$auftrnr='1'; |
|
82 |
$kdnum='1'; |
|
83 |
$pricegroup=''; |
|
84 |
$unit='Stck'; |
|
85 |
$longtxt='2'; |
|
86 |
$invbrne='2'; |
|
87 |
$variantnr='1'; |
|
88 |
$OEinsPart='1'; |
|
89 |
$lager=''; |
|
90 |
?> |
peppershop/confedit.php | ||
---|---|---|
1 |
<? |
|
2 |
// $Id: confedit.php 2009/02/10 14:41:30 hli Exp $ |
|
3 |
if (!isset($_SERVER['PHP_AUTH_USER'])) { |
|
4 |
Header("WWW-Authenticate: Basic realm='Configurations-Editor'"); |
|
5 |
Header("HTTP/1.0 401 Unauthorized"); |
|
6 |
echo "Sie müssen sich autentifizieren\n"; |
|
7 |
exit; |
|
8 |
} else { |
|
9 |
if (!$_POST) { |
|
10 |
//Je Shop ein Conf-File == Multishop |
|
11 |
if( isset($_GET["Shop"]) ) { |
|
12 |
$Shop = $_GET["Shop"]; |
|
13 |
} else { |
|
14 |
$Shop = ''; |
|
15 |
}; |
|
16 |
if ( $Shop != "" and file_exists ('conf'.$Shop.'.php') ) { |
|
17 |
require 'conf'.$Shop.'.php'; |
|
18 |
$out = "Konfiguration für Shop $Shop gelesen"; |
|
19 |
} else { |
|
20 |
//Singleshop oder noch kein Shop definiert |
|
21 |
require "conf.php"; |
|
22 |
$out = "Standard-Konfiguration gelesen"; |
|
23 |
} |
|
24 |
if ( $_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd ) { |
|
25 |
Header("WWW-Authenticate: Basic realm='My Realm'"); |
|
26 |
Header("HTTP/1.0 401 Unauthorized"); |
|
27 |
echo "Sie müssen sich autentifizieren\n"; |
|
28 |
exit; |
|
29 |
} |
|
30 |
echo $out; |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
include_once("error.php"); |
|
35 |
include_once("dblib.php"); |
|
36 |
$api = php_sapi_name(); |
|
37 |
if ( $api == 'cli' ) { |
|
38 |
echo "Nur im Browser benutzen\n"; |
|
39 |
exit(-1); |
|
40 |
}; |
|
41 |
$err = new error($api); |
|
42 |
|
|
43 |
$zeichen = array("","UTF-8","ISO-8859-1","ISO-8859-15","Windows-1252","ASCII"); |
|
44 |
function lager($sel,$db) { |
|
45 |
if (!$db) return ''; |
|
46 |
$sql = "select w.description as lager,b.description as platz,b.id from "; |
|
47 |
$sql .= "bin b left join warehouse w on w.id=b.warehouse_id "; |
|
48 |
$sql .= "order by b.warehouse_id,b.id"; |
|
49 |
$bin=$db->getall($sql); |
|
50 |
echo "\t<option value=-1 ".(($sel==-1)?'selected':'').">kein Lagerbestand\n"; |
|
51 |
echo "\t<option value=1 ".(($sel==1)?'selected':'').">Gesamtbestand\n"; |
|
52 |
if ($bin) foreach ($bin as $row) { |
|
53 |
echo "\t<option value=".$row['id']; |
|
54 |
if ($sel==$row['id']) echo " selected"; |
|
55 |
echo ">".$row['lager']." ".$row['platz']."\n"; |
|
56 |
} |
|
57 |
} |
|
58 |
function unit($sel,$db) { |
|
59 |
if (!$db) return ''; |
|
60 |
$sql="select name from units order by sortkey"; |
|
61 |
$pgs=$db->getall($sql); |
|
62 |
if ($sel=='') $sel=$pgs[0]['name']; |
|
63 |
if ($pgs) foreach ($pgs as $row) { |
|
64 |
echo "\t<option value=".$row['name']; |
|
65 |
if ($sel==$row['name']) echo " selected"; |
|
66 |
echo ">".$row['name']."\n"; |
|
67 |
} |
|
68 |
} |
|
69 |
function pg($sel,$db) { |
|
70 |
if (!$db) return ''; |
|
71 |
$sql="select id,pricegroup from pricegroup"; |
|
72 |
$pgs=$db->getall($sql); |
|
73 |
echo "\t<option value=0"; |
|
74 |
if ($sel==0) echo " selected"; |
|
75 |
echo ">Standard VK\n"; |
|
76 |
if ($pgs) foreach ($pgs as $row) { |
|
77 |
echo "\t<option value=".$row['id']; |
|
78 |
if ($sel==$row['id']) echo " selected"; |
|
79 |
echo ">".$row['pricegroup']."\n"; |
|
80 |
} |
|
81 |
} |
|
82 |
function getTax($db) { |
|
83 |
$sql = "SELECT BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, "; |
|
84 |
$sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, "; |
|
85 |
$sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 "; |
|
86 |
$sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id "; |
|
87 |
$sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id "; |
|
88 |
$sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()"; |
|
89 |
$rs = $db->getAll($sql); |
|
90 |
if ($rs) foreach ($rs as $row) { |
|
91 |
$nr = $row['bugru']; |
|
92 |
if (!$TAX[$nr]) { |
|
93 |
$data = array(); |
|
94 |
$data['startdate'] = $row['startdate']; |
|
95 |
$data['rate'] = $row['rate']*100.0; |
|
96 |
$TAX[$nr] = $data; |
|
97 |
} else if ($TAX[$nr]['startdate'] < $row['startdate']) { |
|
98 |
$TAX[$nr]["startdate"] = $row['startdate']; |
|
99 |
$TAX[$nr]["rate"] = $row['rate']*100.0; |
|
100 |
} |
|
101 |
} |
|
102 |
return $TAX; |
|
103 |
} |
|
104 |
function fputsA($f,$key,$var,$bg=false) { |
|
105 |
$lf="\n"; |
|
106 |
fputs($f,'$'.$key.'["ID"]=\''. $var['ID'].'\';'.$lf); |
|
107 |
fputs($f,'$'.$key.'["NR"]=\''. $var['NR'].'\';'.$lf); |
|
108 |
fputs($f,'$'.$key.'["Unit"]=\''. $var['Unit'].'\';'.$lf); |
|
109 |
fputs($f,'$'.$key.'["TXT"]=\''. $var['TXT'].'\';'.$lf); |
|
110 |
if ($bg) fputs($f,'$'.$key.'["BUGRU"]=\''. $var['BUGRU'].'\';'.$lf); |
|
111 |
if ($bg) fputs($f,'$'.$key.'["TAX"]=\''. $var['TAX'].'\';'.$lf); |
|
112 |
} |
|
113 |
|
|
114 |
if ( isset($_POST["ok"]) ) { |
|
115 |
foreach ($_POST as $key=>$val) { |
|
116 |
${$key} = $val; |
|
117 |
} |
|
118 |
}; |
|
119 |
if ( empty($ERPport) ) $ERPport = '5432'; |
|
120 |
if ( empty($SHOPport) ) $SHOPport = '3306'; |
|
121 |
|
|
122 |
$ok=true; |
|
123 |
$dbP = new mydb($ERPhost,$ERPdbname,$ERPuser,$ERPpass,$ERPport,'pgsql',$err,$debug); |
|
124 |
if (!$dbP->db) { |
|
125 |
$ok=false; |
|
126 |
echo "Keine Verbindung zur ERP<br>"; |
|
127 |
$dbP=false; |
|
128 |
unset($divStd['ID']); |
|
129 |
unset($divVerm['ID']); |
|
130 |
unset($minder['ID']); |
|
131 |
unset($versand['ID']); |
|
132 |
unset($nachn['ID']); |
|
133 |
unset($paypal['ID']); |
|
134 |
unset($treuhand['ID']); |
|
135 |
unset($ERPusr['ID']); |
|
136 |
} else { |
|
137 |
$tax = getTax($dbP); |
|
138 |
$sql="SELECT id,description,unit,buchungsgruppen_id FROM parts where partnumber = '%s'"; |
|
139 |
$rs=$dbP->getOne(sprintf($sql,$divStd['NR'])); |
|
140 |
$divStd['ID']=$rs['id']; |
|
141 |
$divStd['Unit']=$rs['unit']; |
|
142 |
$divStd['BUGRU']=$rs['buchungsgruppen_id']; |
|
143 |
$divStd['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
144 |
$divStd['TXT']=addslashes($rs['description']); |
|
145 |
$rs=$dbP->getOne(sprintf($sql,$divVerm['NR'])); |
|
146 |
$divVerm['ID']=$rs['id']; |
|
147 |
$divVerm['Unit']=$rs['unit']; |
|
148 |
$divVerm['BUGRU']=$rs['buchungsgruppen_id']; |
|
149 |
$divVerm['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
150 |
$divVerm['TXT']=addslashes($rs['description']); |
|
151 |
$rs=$dbP->getOne(sprintf($sql,$versandS['NR'])); |
|
152 |
$versandS['ID']=$rs['id']; |
|
153 |
$versandS['Unit']=$rs['unit']; |
|
154 |
$versandS['BUGRU']=$rs['buchungsgruppen_id']; |
|
155 |
$versandS['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
156 |
if ($versandS['TXT'] == '') $versandS['TXT']=addslashes($rs['description']); |
|
157 |
$rs=$dbP->getOne(sprintf($sql,$versandV['NR'])); |
|
158 |
$versandV['ID']=$rs['id']; |
|
159 |
$versandV['Unit']=$rs['unit']; |
|
160 |
$versandV['BUGRU']=$rs['buchungsgruppen_id']; |
|
161 |
$versandV['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
162 |
if ($versandV['TXT'] == '') $versandV['TXT']=addslashes($rs['description']); |
|
163 |
$rs=$dbP->getOne(sprintf($sql,$nachn['NR'])); |
|
164 |
$nachn['ID']=$rs['id']; |
|
165 |
$nachn['Unit']=$rs['unit']; |
|
166 |
$nachn['BUGRU']=$rs['buchungsgruppen_id']; |
|
167 |
$nachn['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
168 |
if ($nachn['TXT'] == '') $nachn['TXT']=addslashes($rs['description']); |
|
169 |
$rs=$dbP->getOne(sprintf($sql,$minder['NR'])); |
|
170 |
$minder['ID']=$rs['id']; |
|
171 |
$minder['Unit']=$rs['unit']; |
|
172 |
$minder['BUGRU']=$rs['buchungsgruppen_id']; |
|
173 |
$minder['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
174 |
if ($minder['TXT'] == '') $minder['TXT']=addslashes($rs['description']); |
|
175 |
$rs=$dbP->getOne(sprintf($sql,$paypal['NR'])); |
|
176 |
$paypal['ID']=$rs['id']; |
|
177 |
$paypal['Unit']=$rs['unit']; |
|
178 |
$paypal['BUGRU']=$rs['buchungsgruppen_id']; |
|
179 |
$paypal['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
180 |
if ($paypal['TXT'] == '') $paypal['TXT']=addslashes($rs['description']); |
|
181 |
$rs=$dbP->getOne(sprintf($sql,$treuhand['NR'])); |
|
182 |
$treuhand['ID']=$rs['id']; |
|
183 |
$treuhand['Unit']=$rs['unit']; |
|
184 |
$treuhand['BUGRU']=$rs['buchungsgruppen_id']; |
|
185 |
$treuhand['TAX']=$tax[$rs['buchungsgruppen_id']]['rate']; |
|
186 |
if ($treuhand['TXT'] == '') $treuhand['TXT']=addslashes($rs['description']); |
|
187 |
$rs=$dbP->getOne("select id from employee where login = '".$ERPusrName."'"); |
|
188 |
$ERPusrID=$rs['id']; |
|
189 |
} |
|
190 |
$dbM = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug); |
|
191 |
if (!$dbM->db) { |
|
192 |
$ok=false; |
|
193 |
echo "Keine Verbindung zum Shop<br>"; |
|
194 |
$dbM=false; |
|
195 |
}; |
|
196 |
if ( isset($_POST["ok"]) ) { |
|
197 |
$lf = "\n"; |
|
198 |
$f = @fopen('conf'.$Shop.'.php','w'); |
|
199 |
if ($f) { |
|
200 |
$v="1.5"; |
|
201 |
$d=date("Y/m/d H:i:s"); |
|
202 |
fputs($f,"<?php$lf// Verbindung zur ERP-db$lf"); |
|
203 |
fputs($f,'$debug=\''.$debug.'\';'.$lf); |
|
204 |
fputs($f,'$ERPuser=\''.$ERPuser.'\';'.$lf); |
|
205 |
fputs($f,'$ERPpass=\''.$ERPpass.'\';'.$lf); |
|
206 |
fputs($f,'$ERPhost=\''.$ERPhost.'\';'.$lf); |
|
207 |
fputs($f,'$ERPport=\''.$ERPport.'\';'.$lf); |
|
208 |
fputs($f,'$ERPdbname=\''.$ERPdbname.'\';'.$lf); |
|
209 |
fputs($f,'$codeLX=\''.$codeLX.'\';'.$lf); |
|
210 |
fputs($f,'$mwstLX=\''.$mwstLX.'\';'.$lf); |
|
211 |
fputs($f,'$ERPusrName=\''.$ERPusrName.'\';'.$lf); |
|
212 |
fputs($f,'$ERPusrID=\''.$ERPusrID.'\';'.$lf); |
|
213 |
fputs($f,'$ERPimgdir=\''.$ERPimgdir.'\';'.$lf); |
|
214 |
fputs($f,'$maxSize=\''.$maxSize.'\';'.$lf); |
|
215 |
fputs($f,'$ERPftphost=\''.$ERPftphost.'\';'.$lf); |
|
216 |
fputs($f,'$ERPftpuser=\''.$ERPftpuser.'\';'.$lf); |
|
217 |
fputs($f,'$ERPftppwd=\''.$ERPftppwd.'\';'.$lf); |
|
218 |
fputs($f,'//Verbindung zur osCommerce-db'.$lf); |
|
219 |
fputs($f,'$SHOPuser=\''.$SHOPuser.'\';'.$lf); |
|
220 |
fputs($f,'$SHOPpass=\''.$SHOPpass.'\';'.$lf); |
|
221 |
fputs($f,'$SHOPhost=\''.$SHOPhost.'\';'.$lf); |
|
222 |
fputs($f,'$SHOPport=\''.$SHOPport.'\';'.$lf); |
|
223 |
fputs($f,'$SHOPdbname=\''.$SHOPdbname.'\';'.$lf); |
|
224 |
fputs($f,'$codeS=\''.$codeS.'\';'.$lf); |
|
225 |
fputs($f,'$mwstS=\''.$mwstS.'\';'.$lf); |
|
226 |
fputs($f,'$SHOPimgdir=\''.$SHOPimgdir.'\';'.$lf); |
|
227 |
fputs($f,'$SHOPftphost=\''.$SHOPftphost.'\';'.$lf); |
|
228 |
fputs($f,'$SHOPftpuser=\''.$SHOPftpuser.'\';'.$lf); |
|
229 |
fputs($f,'$SHOPftppwd=\''.$SHOPftppwd.'\';'.$lf); |
|
230 |
fputs($f,'$nopic=\''.$nopic.'\';'.$lf); |
|
231 |
fputs($f,'$nopicerr=\''.$nopicerr.'\';'.$lf); |
|
232 |
fputsA($f,'divStd',$divStd,true); |
|
233 |
fputsA($f,'divVerm',$divVerm,true); |
|
234 |
fputsA($f,'versandS',$versandS,true); |
|
235 |
fputsA($f,'versandV',$versandV,true); |
|
236 |
fputsA($f,'minder',$minder,true); |
|
237 |
fputsA($f,'nachn',$nachn,true); |
|
238 |
fputsA($f,'treuhand',$treuhand,true); |
|
239 |
fputsA($f,'paypal',$paypal,true); |
|
240 |
fputs($f,'$bgcol[1]=\'#ddddff\';'.$lf); |
|
241 |
fputs($f,'$bgcol[2]=\'#ddffdd\';'.$lf); |
|
242 |
fputs($f,'$preA=\''.$preA.'\';'.$lf); |
|
243 |
fputs($f,'$preK=\''.$preK.'\';'.$lf); |
|
244 |
fputs($f,'$auftrnr=\''.$auftrnr.'\';'.$lf); |
|
245 |
//fputs($f,'$utftrans=\''.$utftrans.'\';'.$lf); |
|
246 |
fputs($f,'$kdnum=\''.$kdnum.'\';'.$lf); |
|
247 |
fputs($f,'$pricegroup=\''.$pricegroup.'\';'.$lf); |
|
248 |
fputs($f,'$unit=\''.$unit.'\';'.$lf); |
|
249 |
fputs($f,'$longtxt=\''.$longtxt.'\';'.$lf); |
|
250 |
fputs($f,'$invbrne=\''.$invbrne.'\';'.$lf); |
|
251 |
fputs($f,'$variantnr=\''.$variantnr.'\';'.$lf); |
|
252 |
fputs($f,'$OEinsPart=\''.$OEinsPart.'\';'.$lf); |
|
253 |
fputs($f,'$lager=\''.$lager.'\';'.$lf); |
|
254 |
//fputs($f,'$showErr=true;'.$lf); |
|
255 |
fputs($f,"?>"); |
|
256 |
fclose($f); |
|
257 |
echo "Konfiguration conf$Shop.php gesichert."; |
|
258 |
} else { |
|
259 |
echo "Konfigurationsdatei (conf$Shop.php) konnte nicht geschrieben werden"; |
|
260 |
} |
|
261 |
} |
|
262 |
?> |
|
263 |
<html> |
|
264 |
<body> |
|
265 |
<center> |
|
266 |
<table style="background-color:#cccccc" border="0"> |
|
267 |
<form name="ConfEdit" method="post" action="confedit.php"> |
|
268 |
<input type="hidden" name="Shop" value="<?= $Shop ?>"> |
|
269 |
<input type="hidden" name="divStd[ID]" value="<?= $divStd['ID'] ?>"> |
|
270 |
<input type="hidden" name="divVerm[ID]" value="<?= $divVerm['ID'] ?>"> |
|
271 |
<input type="hidden" name="minder[ID]" value="<?= $minder['ID'] ?>"> |
|
272 |
<input type="hidden" name="versandS[ID]" value="<?= $versandS['ID'] ?>"> |
|
273 |
<input type="hidden" name="versandV[ID]" value="<?= $versandV['ID'] ?>"> |
|
274 |
<input type="hidden" name="nachn[ID]" value="<?= $nachn['ID'] ?>"> |
|
275 |
<input type="hidden" name="paypal[ID]" value="<?= $paypal['ID'] ?>"> |
|
276 |
<input type="hidden" name="treuhand[ID]" value="<?= $treuhand['ID'] ?>"> |
|
277 |
<input type="hidden" name="ERPusr[ID]" value="<?= $ERPusr['ID'] ?>"> |
|
278 |
|
|
279 |
<tr><th>Daten</th><th>Lx-ERP</th><th><?php echo $Shop ?></th><th>Shop</th></tr> |
|
280 |
<tr> |
|
281 |
<td>db-Host</td> |
|
282 |
<td colspan="2"><input type="text" name="ERPhost" size="25" value="<?= $ERPhost ?>"></td> |
|
283 |
<td><input type="text" name="SHOPhost" size="25" value="<?= $SHOPhost ?>"></td> |
|
284 |
</tr> |
|
285 |
<tr> |
|
286 |
<td>db-Port</td> |
|
287 |
<td colspan="2"><input type="text" name="ERPport" size="25" value="<?= $ERPport ?>"></td> |
|
288 |
<td><input type="text" name="SHOPport" size="25" value="<?= $SHOPport ?>"></td> |
|
289 |
</tr> |
|
290 |
<tr> |
|
291 |
<td>Database</td> |
|
292 |
<td colspan="2"><input type="text" name="ERPdbname" size="20" value="<?= $ERPdbname ?>"></td> |
|
293 |
<td><input type="text" name="SHOPdbname" size="20" value="<?= $SHOPdbname ?>"></td> |
|
294 |
</tr> |
|
295 |
<tr> |
|
296 |
<td>db-User Name</td> |
|
297 |
<td colspan="2"><input type="text" name="ERPuser" size="15" value="<?= $ERPuser ?>"></td> |
|
298 |
<td><input type="text" name="SHOPuser" size="15" value="<?= $SHOPuser ?>"></td> |
|
299 |
</tr> |
|
300 |
<tr> |
|
301 |
<td>db-User PWD</td> |
|
302 |
<td colspan="2"><input type="text" name="ERPpass" size="15" value="<?= $ERPpass ?>"></td> |
|
303 |
<td><input type="text" name="SHOPpass" size="15" value="<?= $SHOPpass ?>"></td> |
|
304 |
</tr> |
|
305 |
</tr> |
|
306 |
<td>Zeichensatz</td> |
|
307 |
<td colspan="2"><select name="codeLX"> |
|
308 |
<?php foreach($zeichen as $code) { |
|
309 |
echo "<option value='".$code."'"; |
|
310 |
if ($code == $codeLX) echo " selected"; |
|
311 |
echo ">".$code."\n"; }; |
|
312 |
?> |
|
313 |
</select></td> |
|
314 |
<td ><select name="codeS"> |
|
315 |
<?php foreach($zeichen as $code) { |
|
316 |
echo "<option value='".$code."'"; |
|
317 |
if ($code == $codeS) echo " selected"; |
|
318 |
echo ">".$code."\n"; }; |
|
319 |
?> |
|
320 |
</select></td> |
|
321 |
</tr> |
|
322 |
<tr> |
|
323 |
<td>Preise </td> |
|
324 |
<td colspan="2"> <input type="radio" name="mwstLX" value="1" <?= ($mwstLX==1)?"checked":'' ?>> incl. |
|
325 |
<input type="radio" name="mwstLX" value="0" <?= ($mwstLX<>1)?"checked":'' ?>> excl. MwSt</td> |
|
326 |
<td><input type="radio" name="mwstS" value="1" <?= ($mwstS==1)?"checked":'' ?>> incl. |
|
327 |
<input type="radio" name="mwstS" value="0" <?= ($mwstS<>1)?"checked":'' ?>> excl. MwSt</td> |
|
328 |
</tr> |
|
329 |
<tr> |
|
330 |
<td>User-ID</td> |
|
331 |
<td colspan="2"><input type="text" name="ERPusrName" size="10" value="<?= $ERPusrName ?>"> |
|
332 |
<input type="checkbox" name="a1" <?= (empty($ERPusrID)?'':"checked") ?>></td> |
|
333 |
<td></td> |
|
334 |
</tr> |
|
335 |
<tr> |
|
336 |
<td>Image-Dir</td> |
|
337 |
<td colspan="2"><input type="text" name="ERPimgdir" size="30" value="<?= $ERPimgdir ?>"></td> |
|
338 |
<td><input type="text" name="SHOPimgdir" size="30" value="<?= $SHOPimgdir ?>"></td> |
|
339 |
</tr> |
|
340 |
<tr> |
|
341 |
<td>Platzhalterbild</td> |
|
342 |
<td colspan="2"><input type="text" name="nopic" size="20" value="<?php echo $nopic; ?>">ohne Endung</td> |
|
343 |
<td colspan="2"><input type="checkbox" value="1" name="nopicerr" <?= (empty($nopicerr)?'':"checked") ?>>nur bei fehlerhaftem Upload verwenden</td> |
|
344 |
</tr> |
|
345 |
<tr> |
|
346 |
<td>FTP-Host</td> |
|
347 |
<td colspan="2"><input type="text" name="ERPftphost" size="20" value="<?= $ERPftphost ?>"></td> |
|
348 |
<td><input type="text" name="SHOPftphost" size="20" value="<?= $SHOPftphost ?>"></td> |
|
349 |
</tr> |
|
350 |
<tr> |
|
351 |
<td>FTP-User</td> |
|
352 |
<td colspan="2"><input type="text" name="ERPftpuser" size="15" value="<?= $ERPftpuser ?>"></td> |
|
353 |
<td><input type="text" name="SHOPftpuser" size="15" value="<?= $SHOPftpuser ?>"></td> |
|
354 |
</tr> |
|
355 |
<tr> |
|
356 |
<td>FTP-User PWD</td> |
|
357 |
<td colspan="2"><input type="text" name="ERPftppwd" size="15" value="<?= $ERPftppwd ?>"></td> |
|
358 |
<td><input type="text" name="SHOPftppwd" size="15" value="<?= $SHOPftppwd ?>"></td> |
|
359 |
</tr> |
|
360 |
<tr> |
|
361 |
<td>Nr Diverse Std-MwSt</td> |
|
362 |
<td><input type="text" name="divStd[NR]" size="10" value="<?= $divStd['NR'] ?>"> |
|
363 |
<input type="checkbox" name="a1" <?= (empty($divStd['ID'])?'':"checked") ?>></td> |
|
364 |
<td>Nr Diverse Verm-MwSt</td> |
|
365 |
<td><input type="text" name="divVerm[NR]" size="10" value="<?= $divVerm['NR'] ?>"> |
|
366 |
<input type="checkbox" name="a1" <?= (empty($divVerm['ID'])?'':"checked") ?>></td> |
|
367 |
</tr> |
|
368 |
<tr> |
|
369 |
<td>Nr Versand Std-MwSt</td> |
|
370 |
<td><input type="text" name="versandS[NR]" size="10" value="<?= $versandS['NR'] ?>"> |
|
371 |
<input type="checkbox" name="a1" <?= (empty($versandS['ID'])?'':"checked") ?>></td> |
|
372 |
<td>Text:</td> |
|
373 |
<td><input type="text" name="versandS[TXT]" size="20" value="<?= $versandS['TXT'] ?>"><?= $versandS['TAX'] ?></td> |
|
374 |
<tr> |
|
375 |
<td>Nr Versand Verm-MwSt</td> |
|
376 |
<td><input type="text" name="versandV[NR]" size="10" value="<?= $versandV['NR'] ?>"> |
|
377 |
<input type="checkbox" name="a1" <?= (empty($versandV['ID'])?'':"checked") ?>></td> |
|
378 |
<td>Text:</td> |
|
379 |
<td><input type="text" name="versandV[TXT]" size="20" value="<?= $versandV['TXT'] ?>"><?= $versandV['TAX'] ?></td> |
|
380 |
</tr> |
|
381 |
<tr> |
|
382 |
<td>Nr Paypal</td> |
|
383 |
<td><input type="text" name="paypal[NR]" size="10" value="<?= $paypal['NR'] ?>"> |
|
384 |
<input type="checkbox" name="a1" <?= (empty($paypal['ID'])?'':"checked") ?>></td> |
|
385 |
<td>Text:</td> |
|
386 |
<td><input type="text" name="paypal[TXT]" size="20" value="<?= $paypal['TXT'] ?>"></td> |
|
387 |
</tr> |
|
388 |
<tr> |
|
389 |
<td>Nr Treuhand</td> |
|
390 |
<td><input type="text" name="treuhand[NR]" size="10" value="<?= $treuhand['NR'] ?>"> |
|
391 |
<input type="checkbox" name="a1" <?= (empty($treuhand['ID'])?'':"checked") ?>></td> |
|
392 |
<td>Text:</td> |
|
393 |
<td><input type="text" name="treuhand[TXT]" size="20" value="<?= $treuhand['TXT'] ?>"></td> |
|
394 |
</tr> |
|
395 |
<tr> |
|
396 |
<td>Nr Mindermenge</td> |
|
397 |
<td><input type="text" name="minder[NR]" size="10" value="<?= $minder['NR'] ?>"> |
|
398 |
<input type="checkbox" name="a1" <?= (empty($minder['ID'])?'':"checked") ?>></td> |
|
399 |
<td>Text:</td> |
|
400 |
<td><input type="text" name="minder[TXT]" size="20" value="<?= $minder['TXT'] ?>"></td> |
|
401 |
</tr> |
|
402 |
<tr> |
|
403 |
<td>Nr Nachname</td> |
|
404 |
<td><input type="text" name="nachn[NR]" size="10" value="<?= $nachn['NR'] ?>"> |
|
405 |
<input type="checkbox" name="a1" <?= (empty($nachn['ID'])?'':"checked") ?>></td> |
|
406 |
<td>Text:</td> |
|
407 |
<td><input type="text" name="nachn[TXT]" size="20" value="<?= $nachn['TXT'] ?>"></td> |
|
408 |
</tr> |
|
409 |
<tr> |
|
410 |
<td>Std-Einheit</td> |
|
411 |
<td><select name="unit"> |
|
412 |
<? unit($unit,$dbP); ?> |
|
413 |
</select></td> |
|
414 |
<td>Preisgruppe</td> |
|
415 |
<td><select name="pricegroup"> |
|
416 |
<? pg($pricegroup,$dbP); ?> |
|
417 |
</select></td> |
|
418 |
<tr> |
|
419 |
<td colspan="2">Auftragsnummern durch</td> |
|
420 |
<td><input type="radio" name="auftrnr" value="1" <?= ($auftrnr==1)?"checked":'' ?>> LxO</td> |
|
421 |
<td><input type="radio" name="auftrnr" value="0" <?= ($auftrnr<>1)?"checked":'' ?>> Shop</td> |
|
422 |
</tr> |
|
423 |
<tr> |
|
424 |
<td colspan="2">Kundennummern durch</td> |
|
425 |
<td><input type="radio" name="kdnum" value="1" <?= ($kdnum==1)?"checked":'' ?>> LxO</td> |
|
426 |
<td><input type="radio" name="kdnum" value="0" <?= ($kdnum<>1)?"checked":'' ?>> Shop</td> |
|
427 |
</tr> |
|
428 |
<tr> |
|
429 |
<td colspan="2">Nummernerweiterung</td> |
|
430 |
<td>Auftrag<input type="text" name="preA" size="5" value="<?= $preA ?>"></td> |
|
431 |
<td>Kunde<input type="text" name="preK" size="5" value="<?= $preK ?>"></td> |
|
432 |
</tr> |
|
433 |
<tr> |
|
434 |
<td>Lagerbestand aus</td> |
|
435 |
<td><select name="lager"> |
|
436 |
<? lager($lager,$dbP); ?> |
|
437 |
</select></td> |
|
438 |
<td></td> |
|
439 |
<td></td> |
|
440 |
<tr> |
|
441 |
<tr> |
|
442 |
<td colspan="3">Langbeschreibung aus Shop übernehmen</td> |
|
443 |
<td><input type="radio" name="longtxt" value="1" <?= ($longtxt<>2)?"checked":'' ?>>Ja |
|
444 |
<input type="radio" name="longtxt" value="2" <?= ($longtxt==2)?"checked":'' ?>>Nein</td> |
|
445 |
|
|
446 |
</tr> |
|
447 |
<tr> |
|
448 |
<td colspan="3">LxO-Rechnungen sind Netto</td> |
|
449 |
<td><input type="radio" name="invbrne" value="1" <?= ($invbrne<>2)?"checked":'' ?>>Ja |
|
450 |
<input type="radio" name="invbrne" value="2" <?= ($invbrne==2)?"checked":'' ?>>Nein</td> |
|
451 |
</tr> |
|
452 |
<tr> |
|
453 |
<td colspan="3">Varianten sind eigene Nummern in Lx (-n)</td> |
|
454 |
<td><input type="radio" name="variantnr" value="1" <?= ($variantnr<>2)?"checked":'' ?>>Ja |
|
455 |
<input type="radio" name="variantnr" value="2" <?= ($variantnr==2)?"checked":'' ?>>Nein</td> |
|
456 |
</tr> |
|
457 |
<tr> |
|
458 |
<td colspan="3">Unbekannte Artikel beim Bestellimport anlegen</td> |
|
459 |
<td><input type="radio" name="OEinsPart" value="1" <?= ($OEinsPart<>2)?"checked":'' ?>>Ja |
|
460 |
<input type="radio" name="OEinsPart" value="2" <?= ($OEinsPart==2)?"checked":'' ?>>Nein</td> |
|
461 |
</tr> |
|
462 |
<tr> |
|
463 |
<td>Logging</td> |
|
464 |
<td>ein<input type="radio" name="debug" value="true" <?= ($debug=="true")?"checked":"" ?>> |
|
465 |
aus<input type="radio" name="debug" value="false" <?= ($debug!="true")?"checked":"" ?>></td> |
|
466 |
<td></td><td></td> |
|
467 |
</tr> |
|
468 |
|
|
469 |
<!--tr> |
|
470 |
<td>Bildergrösse (byte)</td> |
|
471 |
<td><input type="text" name="maxSize" size="10" value="<?= $maxSize ?>"></td> |
|
472 |
<td></td> |
|
473 |
</tr--> |
|
474 |
|
|
475 |
|
|
476 |
<tr><td colspan="4" align="center"><input type="submit" name="ok" value="sichern"></td></tr> |
|
477 |
</form> |
|
478 |
</table> |
|
479 |
</center> |
|
480 |
</body> |
|
481 |
</html> |
peppershop/dblib.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
include_once("MDB2.php"); |
|
4 |
|
|
5 |
class mydb { |
|
6 |
|
|
7 |
var $db = false; |
|
8 |
var $error = false; |
|
9 |
var $debug = true; |
|
10 |
var $dbf = false; |
|
11 |
var $database = false; |
|
12 |
|
|
13 |
function mydb($host,$db,$user,$pass,$port,$proto,$error,$debug) { |
|
14 |
$this->error = $error; |
|
15 |
$dsn = array('phptype' => $proto, |
|
16 |
'username' => $user, |
|
17 |
'password' => $pass, |
|
18 |
'hostspec' => $host, |
|
19 |
'database' => $db, |
|
20 |
'port' => $port); |
|
21 |
$this->debug = $debug; |
|
22 |
$this->database = "-< $db >-"; |
|
23 |
$this->connect($dsn); |
|
24 |
} |
|
25 |
|
|
26 |
function connect($dsn) { |
|
27 |
$options = array('result_buffering' => false,); |
|
28 |
$this->db = MDB2::connect($dsn,$options); |
|
29 |
if ( $this->debug ) $this->error->write('dblib->connect '.$this->database,'Connect:'); |
|
30 |
if (PEAR::isError($this->db)) { |
|
31 |
$this->error->write('dblib->connect '.$this->database,$this->db->getMessage()); |
|
32 |
$this->error->write('dblib->connect '.$this->database,print_r($dsn,true)); |
|
33 |
$this->db = false; |
|
34 |
return false; |
|
35 |
} |
|
36 |
$this->db->setFetchMode(MDB2_FETCHMODE_ASSOC); |
|
37 |
} |
|
38 |
function Begin() { |
|
39 |
return $this->db->beginTransaction(); |
|
40 |
} |
|
41 |
function Commit() { |
|
42 |
return $this->db->commit(); |
|
43 |
} |
|
44 |
function Rollback() { |
|
45 |
return $this->db->rollback(); |
|
46 |
} |
|
47 |
|
|
48 |
function getAll($sql) { |
|
49 |
$rs = $this->db->queryAll($sql); |
|
50 |
if ( $this->debug ) $this->error->write('dblib->getAll '.$this->database,$sql); |
|
51 |
if (PEAR::isError($rs)) { |
|
52 |
$this->error->write('dblib->getAll '.$this->database,$rs->getUserinfo()); |
|
53 |
return false; |
|
54 |
} |
|
55 |
return $rs; |
|
56 |
} |
|
57 |
|
|
58 |
function getOne($sql) { |
|
59 |
$rs = $this->db->queryRow($sql); |
|
60 |
if ( $this->debug ) $this->error->write('dblib->getOne '.$this->database,$sql); |
|
61 |
if (PEAR::isError($rs)) { |
|
62 |
$this->error->write('dblib->getOne '.$this->database,$rs->getUserinfo()); |
|
63 |
return false; |
|
64 |
} |
|
65 |
return $rs; |
|
66 |
} |
|
67 |
function query($sql) { |
|
68 |
$rc = $this->db->query($sql); |
|
69 |
if ( $this->debug ) $this->error->write('dblib->query '.$this->database,$sql); |
|
70 |
if (PEAR::isError($rc)) { |
|
71 |
$this->error->write('dblib->query '.$this->database,$rc->getUserinfo()); |
|
72 |
return false; |
|
73 |
} |
|
74 |
return $rc; |
|
75 |
} |
|
76 |
function insert($statement,$data) { |
|
77 |
if ( $this->debug ) $this->error->write("dblib->insert ".$this->database,$statement); |
|
78 |
$sth = $this->db->prepare($statement); //Prepare |
|
79 |
if (PEAR::isError($sth)) { |
|
80 |
$this->error->write('dblib->insert 1 '.$this->database,$sth->getMessage()); |
|
81 |
$this->error->write('dblib->insert 2',$sth->getUserinfo()); |
|
82 |
$this->rollback(); |
|
83 |
return false; |
|
84 |
} |
|
85 |
if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true)); |
|
86 |
$rc =& $sth->execute($data); |
|
87 |
if (PEAR::isError($rc)) { |
|
88 |
$this->error->write('dblib->insert 3 '.$this->database,$rc->getUserinfo()); |
|
89 |
return false; |
|
90 |
}//else{ |
|
91 |
// $rc = $this->commit(); |
|
92 |
//} |
|
93 |
return $rc; |
|
94 |
} |
|
95 |
function update($statement,$data) { |
|
96 |
if ( $this->debug ) $this->error->write("dblib->update ".$this->database,$statement); |
|
97 |
$sth = $this->db->prepare($statement); //Prepare |
|
98 |
if (PEAR::isError($sth)) { |
|
99 |
$this->error->write('dblib->update 1 '.$this->database,$sth->getMessage()); |
|
100 |
$this->error->write('dblib->update 2',$sth->getUserinfo()); |
|
101 |
$this->rollback(); |
|
102 |
return false; |
|
103 |
} |
|
104 |
if ( $this->debug ) $this->error->write('dblib->insert',print_r($data,true)); |
|
105 |
$rc =& $sth->execute($data); |
|
106 |
if (PEAR::isError($rc)) { |
|
107 |
$this->error->write('dblib->update 3 '.$this->database,$rc->getUserinfo()); |
|
108 |
return false; |
|
109 |
}//else{ |
|
110 |
// $rc = $this->commit(); |
|
111 |
//} |
|
112 |
return $rc; |
|
113 |
} |
|
114 |
function insertMultipe($statement,$data) { |
|
115 |
$this->db->loadModule('Extended'); |
|
116 |
if (!$this->db->supports('transactions')){ |
|
117 |
return false; |
|
118 |
} |
|
119 |
$sth = $this->db->prepare($statement); //Prepare |
|
120 |
if (PEAR::isError($sth)) { |
|
121 |
$this->error->write('dblib->insertMultiple '.$this->database,$sth->getMessage()); |
|
122 |
$this->rollback(); |
|
123 |
return false; |
|
124 |
} |
|
125 |
$rc =& $this->db->beginTransaction(); |
|
126 |
$rc =& $this->db->extended->executeMultiple($sth, $data); |
|
127 |
if (PEAR::isError($rc)) { |
|
128 |
$this->error->write('dblib->insertMultiple '.$this->database,$rc->getUserinfo()); |
|
129 |
$this->rollback(); |
|
130 |
return false; |
|
131 |
}else{ |
|
132 |
$rc = $this->commit(); |
|
133 |
} |
|
134 |
return $rc; |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
?> |
peppershop/erplib.php | ||
---|---|---|
1 |
<?php |
|
2 |
/* |
|
3 |
|
|
4 |
shop muß gesetzt sein, obsolet nicht |
|
5 |
|
|
6 |
Multishop: Hierfür müssen benutzerdefinierte Variablen angelegt werden. |
|
7 |
Typ:checkbox, Name=shop[0-9A-Z]+, Bearbeitbar=nein |
|
8 |
|
|
9 |
|
|
10 |
*/ |
|
11 |
|
|
12 |
class erp { |
|
13 |
|
|
14 |
var $db = false; |
|
15 |
var $error = false; |
|
16 |
var $pricegroup = 0; |
|
17 |
var $TAX = false; |
|
18 |
var $mkPart = true; |
|
19 |
var $divStd = false; |
|
20 |
var $divVerm = false; |
|
21 |
var $doordnr = false; |
|
22 |
var $docustnr = false; |
|
23 |
var $lager = 1; |
|
24 |
var $warehouse_id = 0; |
|
25 |
var $transtype = 0; |
|
26 |
var $preordnr = ''; |
|
27 |
var $precustnr = ''; |
|
28 |
var $OEinsPart = false; |
|
29 |
var $INVnetto = true; //Rechnungen mit Nettopreisen |
|
30 |
var $SHOPincl = true; //Shoppreise sind Brutto |
|
31 |
|
|
32 |
function erp($db,$error,$divStd,$divVerm,$doordnr,$docustnr,$preordnr,$precustnr,$INVnetto,$SHOPincl,$OEinsPart,$lager,$pricegroup,$ERPusrID) { |
|
33 |
$this->db = $db; |
|
34 |
$this->pricegroup = $pricegroup; |
|
35 |
$this->employee_id = $ERPusrID; |
|
36 |
$this->error = $error; |
|
37 |
$this->divStd = $divStd; |
|
38 |
$this->divVerm = $divVerm; |
|
39 |
$this->doordnr = $doordnr; |
|
40 |
$this->preordnr = $preordnr; |
|
41 |
$this->docustnr = $docustnr; |
|
42 |
$this->precustnr = $precustnr; |
|
43 |
$this->INVnetto = ($INVnetto == 1)?true:false; |
|
44 |
$this->SHOPincl = ($SHOPincl == 1)?true:false; |
|
45 |
$this->OEinsPart = ($OEinsPart == 1)?true:false; |
|
46 |
$this->lager = ($lager)?$lager:1; |
|
47 |
$this->getTax(); |
|
48 |
if ( $lager > 1 ) { |
|
49 |
$sql = "SELECT warehouse_id from bin where id = ".$this->lager; |
|
50 |
$rs = $this->db->getOne($sql); |
|
51 |
if ( $rs['warehouse_id'] > 0 ) { |
|
52 |
$this->warehouse_id = $rs['warehouse_id']; |
|
53 |
$sql = "SELECT id from transfer_type WHERE direction = 'in' and description = 'stock'"; |
|
54 |
$rs = $this->db->getOne($sql); |
|
55 |
$this->transtype = $rs['id']; |
|
56 |
} else { |
|
57 |
$this->lager = 1; |
|
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
function getTax() { |
|
63 |
$sql = "SELECT BG.id AS bugru,T.rate,TK.startdate,C.taxkey_id, "; |
|
64 |
$sql .= "(SELECT id FROM chart WHERE accno = T.taxnumber) AS tax_id, "; |
|
65 |
$sql .= "BG.income_accno_id_0,BG.expense_accno_id_0 "; |
|
66 |
$sql .= "FROM buchungsgruppen BG LEFT JOIN chart C ON BG.income_accno_id_0=C.id "; |
|
67 |
$sql .= "LEFT JOIN taxkeys TK ON TK.chart_id=C.id "; |
|
68 |
$sql .= "LEFT JOIN tax T ON T.id=TK.tax_id WHERE TK.startdate <= now()"; |
|
69 |
$rs = $this->db->getAll($sql); |
|
70 |
if ($rs) foreach ($rs as $row) { |
|
71 |
$nr = $row['bugru']; |
|
72 |
if ( !$this->TAX[$nr] || !array_key_exists($nr, $this->TAX) ) { |
|
73 |
$data = array(); |
|
74 |
$data['startdate'] = $row['startdate']; |
|
75 |
$data['rate'] = $row['rate']; |
|
76 |
$data['taxkey'] = $row['taxkey_id']; |
|
77 |
$data['taxid'] = $row['tax_id']; |
|
78 |
$data['income'] = $row['income_accno_id_0']; |
|
79 |
$data['expense'] = $row['expense_accno_id_0']; |
|
80 |
$this->TAX[$nr] = $data; |
|
81 |
} else if ($this->TAX[$nr]['startdate'] < $row['startdate']) { |
|
82 |
$this->TAX[$nr]["startdate"] = $row['startdate']; |
|
83 |
$this->TAX[$nr]["rate"] = $row['rate']; |
|
84 |
$this->TAX[$nr]["taxkey"] = $row['taxkey_id']; |
|
85 |
$this->TAX[$nr]["taxid"] = $row['tax_id']; |
|
86 |
$this->TAX[$nr]["income"] = $row['income_accno_id_0']; |
|
87 |
$this->TAX[$nr]["expense"] = $row['expense_accno_id_0']; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
function getParts($stdprice=0,$shop=0) { |
|
93 |
$where = "WHERE 1=1 "; |
|
94 |
if ($stdprice>0) { |
|
95 |
$sql = "SELECT P.partnumber,P.description,P.notes,P.weight,G.price as sellprice,P.sellprice as stdprice,"; |
|
96 |
$sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit"; |
|
97 |
if ($this->lager>1) { |
|
98 |
$sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand "; |
|
99 |
} else { |
|
100 |
$sql .= ",P.onhand "; |
|
101 |
} |
|
102 |
$sql .= "FROM parts P "; |
|
103 |
$sql .= "LEFT JOIN partsgroup PG on PG.id=P.partsgroup_id "; |
|
104 |
$sql .= "LEFT JOIN prices G on G.parts_id=P.id "; |
|
105 |
$where .= "AND (G.pricegroup_id=$stdprice "; |
|
106 |
$where .= "or G.pricegroup_id is null) "; |
|
107 |
} else { |
|
108 |
$sql = "SELECT P.partnumber,P.description,P.notes,P.weight,P.sellprice,"; |
|
109 |
$sql .= "PG.partsgroup,P.image,P.buchungsgruppen_id as bugru,P.unit "; |
|
110 |
if ($this->lager>1) { |
|
111 |
$sql .= ",(select sum(qty) from inventory where bin_id = ".$this->lager." and parts_id = P.id) as onhand "; |
|
112 |
} else { |
|
113 |
$sql .= ",P.onhand "; |
|
114 |
} |
|
115 |
$sql .= "FROM parts P left join partsgroup PG on PG.id=P.partsgroup_id "; |
|
116 |
} |
|
117 |
if ($shop>0) { |
|
118 |
$sql .= "LEFT JOIN custom_variables CV on CV.trans_id=P.id "; |
|
119 |
$where .= "AND (CV.config_id = $shop AND bool_value = 't')"; |
|
120 |
} |
|
121 |
$where .= "AND shop = 't' "; |
|
122 |
$where .= "AND obsolete = 'f' ORDER BY P.partnumber"; |
|
123 |
$rs = $this->db->getAll($sql.$where); |
|
124 |
if ($rs) for($i = 0; $i < count($rs); $i++) { |
|
125 |
$rs[$i]['tax'] = $this->TAX[$rs[$i]['bugru']]['rate']; |
|
126 |
} |
|
127 |
return $rs; |
|
128 |
} |
|
129 |
|
|
130 |
function getPartsLang($lang,$alle) { |
|
131 |
$sql = "SELECT P.partnumber,L.translation,P.description,L.longdescription,P.notes,PG.partsgroup "; |
|
132 |
$sql .= "FROM parts P left join translation L on L.parts_id=P.id left join partsgroup PG on PG.id=P.partsgroup_id "; |
|
133 |
$sql .= "WHERE P.shop='t' and (L.language_id = $lang"; |
|
134 |
if ($alle) { |
|
135 |
$sql .= " or L.language_id is Null)"; |
|
136 |
} else { |
|
137 |
$sql.=")"; |
|
138 |
}; |
|
139 |
$rs = $this->getAll($sql); |
|
140 |
$data=array(); |
|
141 |
if ($rs) foreach ($rs as $row) { |
|
142 |
if (!$data[$row["partnumber"]]) $data[$row["partnumber"]]=$row; |
|
143 |
} |
|
144 |
return $data; |
|
145 |
} |
|
146 |
function getNewNr($typ) { |
|
147 |
/* |
|
148 |
so = Auftragsnummer |
|
149 |
customer = Kundennummer |
|
150 |
*/ |
|
151 |
$typ .= "number"; |
|
152 |
$sql = "SELECT $typ FROM defaults"; |
|
153 |
$rs = $this->db->getOne($sql); |
|
154 |
$i=strlen($rs["$typ"])-1; |
|
155 |
//Nummern können Buchstaben, Zeichen und Zahlen enthalten |
|
156 |
//nur die Zahlen von rechts werden aber inkrementiert. |
|
157 |
while($i>=0) { |
|
158 |
if ($rs["$typ"][$i] >= "0" and $rs["$typ"][$i]<="9") { |
|
159 |
$n=$rs["$typ"][$i].$n; |
|
160 |
$i--; |
|
161 |
} else { |
|
162 |
$pre = substr($rs["$typ"],0,$i+1); |
|
163 |
$i=-1; |
|
164 |
} |
|
165 |
}; |
|
166 |
$nr = (int)$n + 1; |
|
167 |
$sonr = $pre.$nr; |
|
168 |
$sql = "UPDATE defaults SET $typ = '$sonr'"; |
|
169 |
$rc = $this->db->query($sql); |
|
170 |
if (!$rc) { |
|
171 |
$this->error->write('erplib','Neue Nummer ($typ) nicht gesichert: '.$sonr); |
|
172 |
} |
|
173 |
return $sonr; |
|
174 |
} |
|
175 |
function newOrder($data) { |
|
176 |
/*Einen neuen Auftrag anlegen. Folgendes Array muß übergeben werden: |
|
177 |
$data = array(ordnumber,customer_id,employee_id,taxzone_id,amount,netamount,transdate,notes,intnotes,shipvia) |
|
178 |
Rückgabe oe.id */ |
|
179 |
$this->db->begin(); |
|
180 |
$incltax = ($this->INVnetto)?'f':'t'; |
|
181 |
$sql = "INSERT INTO oe (ordnumber,customer_id,employee_id,taxzone_id,taxincluded,curr,amount,netamount,transdate,notes,intnotes,shipvia,cusordnumber) "; |
|
182 |
$sql .= "values (:ordnumber,:customer_id,:employee_id,:taxzone_id,'$incltax',:curr,:amount,:netamount,:transdate,:notes,:intnotes,:shipvia,:cusordnumber)"; |
|
183 |
$rc = $this->db->insert($sql,$data); |
|
184 |
$sql = "SELECT * FROM oe where ordnumber = '".$data["ordnumber"]."'"; |
|
185 |
$rs = $this->db->getOne($sql); |
|
186 |
if (!$rs['id']) { |
|
187 |
$this->error->write('erplib','Auftrag erzeugen: '.$data["ordnumber"]); |
|
188 |
$this->db->rollback(); |
|
189 |
return false; |
|
190 |
} else { |
|
191 |
$this->error->out(" Auftrag: ".$data["ordnumber"]." "); |
|
192 |
return $rs['id']; |
|
193 |
} |
|
194 |
} |
|
195 |
function insParts($trans_id,$data,$longtxt) { |
|
196 |
/*Artikel in die orderitem einfügen. Folgende Daten müssen übergeben werden: |
|
197 |
$trans_id = (int) oe.id |
|
198 |
$data = array(trans_id,partnumber,description,longdescription,qty,sellprice,unit)*/ |
|
199 |
foreach ($data as $row) { |
|
200 |
$row['trans_id'] = $trans_id; |
|
201 |
//$sql = "SELECT id FROM parts WHERE partnumber = '".$row['partnumber']."'"; |
|
202 |
//$tmp = $this->db->getOne($sql); |
|
203 |
$tmp = $this->chkPartnumber($row,$this->OEinsPart,true); |
|
204 |
if ($tmp) { |
|
205 |
$row['parts_id'] = $tmp['id']; |
|
206 |
} else { |
|
207 |
if ($this->TAX[$this->divStd['BUGRU']]['rate'] == $row['mwst']/100) { |
|
208 |
$row['parts_id'] = $this->divStd['ID']; |
|
209 |
} else if ($this->TAX[$this->divVerm['BUGRU']]['rate'] == $row['mwst']/100) { |
|
210 |
$row['parts_id'] = $this->divVerm['ID']; |
|
211 |
} else { |
|
212 |
$row['parts_id'] = $this->divStd['ID']; |
|
213 |
} |
|
214 |
} |
|
215 |
if ($this->INVnetto) { |
|
216 |
if ($this->SHOPincl) |
|
217 |
$row['sellprice'] = round($row['sellprice'] / (100 + $row['taxrate']) * 100,2); |
|
218 |
} else { |
|
219 |
if (!$this->SHOPincl) |
|
220 |
$row['sellprice'] = round($row['sellprice'] * (100 + $row['taxrate']) * 100,2); |
|
221 |
} |
|
222 |
$row['unit'] = $this->chkUnit($row['unit']); |
|
223 |
if ($longtxt == 1) { |
|
224 |
//$row['longdescription'] = addslashes($row['longdescription']); |
|
225 |
$row['longdescription'] = $row['longdescription']; |
|
226 |
} else { |
|
227 |
//$row['longdescription'] = addslashes($tmp['longdescription']); |
|
228 |
$row['longdescription'] = $tmp['longdescription']; |
|
229 |
} |
|
230 |
//$row['description'] = addslashes($row['description']); |
|
231 |
$sql = "INSERT INTO orderitems (trans_id,parts_id,description,longdescription,qty,sellprice,unit,pricegroup_id,discount) "; |
|
232 |
$sql .= "VALUES (:trans_id,:parts_id,:description,:longdescription,:qty,:sellprice,:unit,0,0)"; |
|
233 |
$row["trans_id"]=$trans_id; |
|
234 |
$rc = $this->db->insert($sql,$row); |
|
235 |
if (!$rc) { |
|
236 |
$this->db->rollback(); |
|
237 |
return false; |
|
238 |
}; |
|
239 |
}; |
|
240 |
$this->db->commit(); |
|
241 |
return true; |
|
242 |
} |
|
243 |
function insCustomer($data) { |
|
244 |
$this->error->out('Insert:'.$data["name"].' '); |
|
245 |
if ($this->docustnr == 1) { |
|
246 |
$data['customernumber'] = $this->getNewNr('customer'); |
|
247 |
} else { |
|
248 |
$data['customernumber'] = $data['shopid']; |
|
249 |
} |
|
250 |
$data['customernumber'] = $this->precustnr.$data['customernumber']; |
|
251 |
if ($data['customernumber']>0) { |
|
252 |
if (!$data['greeting']) $data['greeting'] = ''; |
|
253 |
$sql = "INSERT INTO customer (greeting,name,street,city,zipcode,country,contact,phone,email,customernumber)"; |
|
254 |
$sql .= " VALUES (:greeting,:name,:street,:city,:zipcode,:country,:contact,:phone,:email,:customernumber)"; |
|
255 |
$rc = $this->db->insert($sql,$data); |
|
256 |
$sql = "SELECT id FROM customer WHERE customernumber = '".$data['customernumber']."'"; |
|
257 |
$rs = $this->db->getOne($sql); |
|
258 |
$rc = $rs['id']; |
|
259 |
$this->error->out("Kd-Nr: ".$data['customernumber'].":".$rs['id']); |
|
260 |
} else { |
|
261 |
$this->error->write('erplib','Kunde anlegen: '.$data["name"]); |
|
262 |
$this->db->rollback(); |
|
263 |
return false; |
|
264 |
} |
|
265 |
return $rc; |
|
266 |
} |
|
267 |
function chkCustomer($data) { |
|
268 |
if ($data['customer_id']>0) { |
|
269 |
$sql = "SELECT * FROM customer WHERE id = ".$data['customer_id']; |
|
270 |
$rs = $this->db->getOne($sql); |
|
271 |
if ($rs['id'] == $data['customer_id']) { |
|
272 |
$this->error->out('Update:'.$data['customer_id'].' '); |
|
273 |
$sql = "UPDATE customer SET greeting = :greeting,name = :name,street = :street,city = :city,country = :country,"; |
|
274 |
$sql .= "zipcode = :zipcode,contact = :contact,phone = :phone,email = :email WHERE id = :customer_id"; |
|
275 |
$rc = $this->db->update($sql,$data); |
|
276 |
if ($rc) $rc = $data['customer_id']; |
|
277 |
} else { |
|
278 |
$rc = $this->insCustomer($data); |
|
279 |
} |
|
280 |
} else { |
|
281 |
$rc = $this->insCustomer($data); |
|
282 |
} |
|
283 |
return $rc; |
|
284 |
} |
|
285 |
function mkAuftrag($data,$shop,$longtxt) { |
|
286 |
$this->db->Begin(); |
|
287 |
$data["notes"] .= "\nBezahlung:".$data['bezahlung']."\n"; |
|
288 |
if ($data['bezahlung'] == "Kreditkarte") $data["notes"] .= $data['kreditkarte']."\n"; |
|
289 |
if ($shop) { |
|
290 |
$data["intnotes"] = "Shop: $shop"; |
|
291 |
} else { |
|
292 |
$data["intnotes"] = ""; |
|
293 |
}; |
|
294 |
$data["customer_id"] = $this->chkCustomer($data["customer"]); |
|
295 |
$parts = $data['parts']; |
|
296 |
unset($data['parts']); |
|
297 |
unset($data['customer']); |
|
298 |
if ($this->doordnr == 1) { |
|
299 |
$data["ordnumber"] = $this->getNewNr('so'); |
|
300 |
} else { |
|
301 |
$data["ordnumber"] = $data['cusordnumber']; |
|
302 |
} |
|
303 |
$data["ordnumber"] = $this->preordnr.$data["ordnumber"]; |
|
304 |
$tid = $this->newOrder($data); |
|
305 |
if ($tid) { |
|
306 |
$rc = $this->insParts($tid,$parts,$longtxt); |
|
307 |
if (!$rc) { |
|
308 |
$this->error->write('erplib','Artikel zu Auftrag'); |
|
309 |
return -1; |
|
310 |
} |
|
311 |
} else { |
|
312 |
$this->error->write('erplib','Auftrag anlegen'); |
|
313 |
return -1; |
|
314 |
} |
|
315 |
$this->error->out($data["customer"]["firma"]." "); |
|
316 |
$rc = $this->db->Commit(); |
|
317 |
return $data["customer_id"]; |
|
318 |
} |
|
319 |
function chkPartsgroup($pg,$new=True) { |
|
320 |
/*gibt es die Warengruppe? |
|
321 |
Rückgabe nichts oder die partsgroup.id |
|
322 |
ggf neu anlegen*/ |
|
323 |
$sql = "SELECT * FROM partsgroup WHERE partsgroup = '".$pg."'"; |
|
324 |
$rs = $this->db->getOne($sql); |
|
325 |
if ($rs) { |
|
326 |
return $rs['id']; |
|
327 |
} else if ($this->mkPart and $new) { |
|
328 |
return $this->mkNewPartsgroup($pg); |
|
329 |
} else { |
|
330 |
return ''; |
|
331 |
}; |
|
332 |
} |
|
333 |
function mkNewPartsgroup($name) { |
|
334 |
$sql = "INSERT INTO partsgroup (partsgroup) VALUES ('".$name."')"; |
|
335 |
$rc = $this->db->query($sql); |
|
336 |
if ($rc) { |
|
337 |
return $this->chkPartsgroup($name,False); |
|
338 |
} else { |
Auch abrufbar als: Unified diff
PHP-Code aus ERP entfernt. Wird als Extrapakete angeboten.