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