| 28 |
lars |
1 |
<?php
|
|
|
2 |
namespace Weban;
|
|
|
3 |
class Shop
|
|
|
4 |
{
|
|
|
5 |
public function __construct()
|
| 30 |
lars |
6 |
{
|
| 28 |
lars |
7 |
ini_set( "display_errors", false );
|
|
|
8 |
ini_set( "default_charset", "utf-8" );
|
| 30 |
lars |
9 |
setlocale( LC_TIME, "de_DE.UTF-8" );
|
| 28 |
lars |
10 |
define( "__USE_MDB2__", true );
|
|
|
11 |
define( "USE_SMARTY", true );
|
|
|
12 |
define( "USE_SMARTY_PAGINATE", false );
|
|
|
13 |
define( "USE_LOGGING", true );
|
|
|
14 |
define( "USE_TRANSLATION2", true );
|
|
|
15 |
|
|
|
16 |
require_once "module/functions.common.php";
|
|
|
17 |
|
|
|
18 |
init_shop();
|
|
|
19 |
|
| 30 |
lars |
20 |
require_once "classes/aktion.class.php";
|
| 32 |
lars |
21 |
require_once "classes/aktionItems.class.php";
|
| 28 |
lars |
22 |
require_once "classes/hersteller.class.php";
|
|
|
23 |
require_once "classes/artikel_bild.class.php";
|
|
|
24 |
require_once "classes/directory_bild.class.php";
|
|
|
25 |
require_once "classes/directory.class.php";
|
|
|
26 |
require_once "classes/randelement.class.php";
|
|
|
27 |
require_once "classes/artikel.class.php";
|
|
|
28 |
require_once "classes/navigation.class.php";
|
|
|
29 |
require_once "classes/basket.class.php";
|
|
|
30 |
|
|
|
31 |
session_start();
|
| 30 |
lars |
32 |
}
|
| 28 |
lars |
33 |
public function run()
|
| 30 |
lars |
34 |
{
|
|
|
35 |
|
| 29 |
lars |
36 |
$is_basket = ( $_SESSION["SHOP"]["BASKET"] instanceof basket );
|
|
|
37 |
if ( ! $is_basket )
|
|
|
38 |
{
|
|
|
39 |
$_SESSION["SHOP"]["BASKET"] = new basket();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
$nav = navigation::nav();
|
|
|
43 |
|
|
|
44 |
$GLOBALS["ui"]->assign( "car", false );
|
|
|
45 |
$GLOBALS["ui"]->assign( "nav", $nav );
|
|
|
46 |
$GLOBALS["ui"]->assign( "skl", randelement::Liste( "links" ) );
|
|
|
47 |
$GLOBALS["ui"]->assign( "skr", randelement::Liste( "rechts" ) );
|
|
|
48 |
$GLOBALS["ui"]->assign( "ini", $GLOBALS["INI"] );
|
|
|
49 |
$GLOBALS["ui"]->assign( "langstrings", $GLOBALS["langstrings"] );
|
|
|
50 |
|
| 28 |
lars |
51 |
if ( isset( $_GET["navigation"] ) && $_GET["navigation"] )
|
|
|
52 |
{
|
|
|
53 |
$subdirs = directory::Liste( $_GET["navigation"] );
|
|
|
54 |
$artikel = artikel::Liste( $_GET["navigation"] );
|
|
|
55 |
$shopPosition = shopPosition( $_GET["navigation"] );
|
|
|
56 |
$GLOBALS["ui"]->assign( "shopPosition", $shopPosition );
|
|
|
57 |
$subdir["items"] = $artikel;
|
|
|
58 |
$subdir["subdirs"] = $subdirs;
|
|
|
59 |
$GLOBALS["ui"]->assign( "subdir", $subdir );
|
|
|
60 |
$GLOBALS["ui"]->assign( "file", "subdir.tpl" );
|
|
|
61 |
}
|
|
|
62 |
elseif ( isset( $_GET["item"] ) && $_GET["item"] && ! isset( $_GET["basket"] ) )
|
|
|
63 |
{
|
|
|
64 |
$item = new artikel( $_GET["item"] );
|
|
|
65 |
$shopPosition = shopPosition( $item->father );
|
| 30 |
lars |
66 |
$shopPosition[] = $item;
|
| 28 |
lars |
67 |
$GLOBALS["ui"]->assign( "shopPosition", $shopPosition );
|
| 30 |
lars |
68 |
$GLOBALS["ui"]->assign( "item", $item )->assign( "file",
|
|
|
69 |
"item.tpl" );
|
| 28 |
lars |
70 |
}
|
|
|
71 |
elseif ( isset( $_GET["basket"] ) && $_GET["basket"] == "true" )
|
|
|
72 |
{
|
|
|
73 |
if ( isset( $_GET["item"] ) && $_GET["item"] && isset( $_GET["menge"] ) &&
|
|
|
74 |
$_GET["menge"] )
|
|
|
75 |
{
|
|
|
76 |
$_SESSION["SHOP"]["BASKET"]->addItem( $_GET["item"], $_GET["menge"] );
|
|
|
77 |
}
|
|
|
78 |
elseif ( isset( $_GET["del"] ) )
|
|
|
79 |
{
|
|
|
80 |
$_SESSION["SHOP"]["BASKET"]->delete( $_GET["del"] );
|
|
|
81 |
sort( $_SESSION["SHOP"]["BASKET"]->items );
|
|
|
82 |
}
|
|
|
83 |
$GLOBALS["ui"]->assign( "file", "basket.tpl" );
|
| 30 |
lars |
84 |
}
|
|
|
85 |
elseif ( isset( $_GET["buy"] ) && $_GET["buy"] == "true" )
|
|
|
86 |
{
|
| 28 |
lars |
87 |
$step = 1;
|
|
|
88 |
if ( in_array( $_GET["step"], array(
|
|
|
89 |
1,
|
|
|
90 |
2,
|
|
|
91 |
3,
|
|
|
92 |
4,
|
|
|
93 |
) ) || ! isset( $_GET["step"] ) )
|
|
|
94 |
{
|
|
|
95 |
if ( $_GET["step"] )
|
|
|
96 |
{
|
|
|
97 |
$step = $_GET["step"];
|
|
|
98 |
}
|
|
|
99 |
$_SESSION["SHOP"]["buy"]["step"] = $step;
|
|
|
100 |
$GLOBALS["ui"]->assign( "file", "buy.tpl" );
|
|
|
101 |
}
|
|
|
102 |
}
|
| 31 |
lars |
103 |
else
|
|
|
104 |
{
|
|
|
105 |
$aktion = Aktion::currentAktion();
|
|
|
106 |
var_dump( $aktion );
|
|
|
107 |
}
|
| 28 |
lars |
108 |
|
|
|
109 |
foreach ( $_SESSION["SHOP"]["BASKET"]->items as $b_id => $item )
|
|
|
110 |
{
|
|
|
111 |
$basketContent["items"][] = array(
|
|
|
112 |
"item" => new artikel( $item["ID"] ),
|
|
|
113 |
"menge" => $item["menge"],
|
|
|
114 |
"preis" => $item["preis"],
|
|
|
115 |
"basketItemSumme" => $item["basketItemSumme"],
|
|
|
116 |
);
|
|
|
117 |
$basketSumme += $item["basketItemSumme"];
|
|
|
118 |
}
|
|
|
119 |
$basketContent["mwst"] = $basketSumme * 19 / 119;
|
|
|
120 |
$basketContent["basketSumme"] = $basketSumme;
|
|
|
121 |
$GLOBALS["ui"]->assign( "basketContent", $basketContent );
|
|
|
122 |
$GLOBALS["ui"]->display( "page.tpl" );
|
| 30 |
lars |
123 |
|
|
|
124 |
}
|
|
|
125 |
public function __destruct()
|
|
|
126 |
{
|
|
|
127 |
unset( $GLOBALS["db"], $GLOBALS["order_db"] );
|
|
|
128 |
}
|
| 28 |
lars |
129 |
}
|
| 30 |
lars |
130 |
?>
|