Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
    /* $Id: Weban_Shop.class.php 21 2007-12-07 09:04:37Z markus $ */
3
 
4
    /**
5
     * Shop module class. This builds the Base class for
6
     * the shop module and is created for further updates.
7
     *
8
     * This class handles the traffic between a client and the
9
     * server. My clou is to put any used Function in a Method
10
     * formate and replace them with the original.
11
     *
12
     * PHP versions 4 and 5
13
     *
14
     * LICENSE: This source file is subject to version 3.0 of the PHP license
15
     * that is available through the world-wide-web at the following URI:
16
     * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
17
     * the PHP License and are unable to obtain it through the web, please
18
     * send a note to license@php.net so we can mail you a copy immediately.
19
     *
20
     * @category   Shop
21
     * @package    Weban_Shop
22
     * @author     Markus Niewerth <markus@weban.de>
23
     * @copyright  1997-2005 The PHP Group
24
     * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
25
     * @since      File available since Release 1.0.1
26
     */
27
 
28
 
29
    // {{{ constants
30
    define( '__BASELANGUAGE__', 'DE' );
31
    define( '__SHOP_ID__', 1 );
32
    define( '__TEMPLATE_EXTENSION__', '.htm' );
33
    define( '__IMAGE_POPUP_TAG__', file_get_contents("templates/Weban_Shop/image.htm", true) );
34
    define( '__IMAGE_EMAIL_INPUT__', $_SESSION['INI']['emailInputImage'] );
35
    define( '__EMAIL_IMAGE_CONTENT_TYPE__', $_SESSION['INI']['emailImageOutput'] );
36
    define( '__GD_TTF_FONT__', $_SESSION['INI']['gdTTFFont'] );
37
 
38
    // }}}
39
    // {{{ GLOBALS
40
 
41
    // -------------------
42
    // IF any put in here!
43
    // -------------------
44
 
45
    // }}}
46
    // {{{ Weban_Shop
47
 
48
    /**
49
     * Dies bildet die Basis Klasse f�r das Shop Modul.
50
     *
51
     * Diese Klasse bildet die Schnittstelle zwischen dem Client
52
     * und dem Server und wird die Funktionssyntax abl�sen.
53
     * Neue Funktionen werden nur noch in Form von Methoden
54
     * implementiert. Alle �lteren Funktionen sollten wenn m�glich
55
     * hier als Methoden implementiert werden.
56
     *
57
     * Funktionen k�nnen aber auch in einer Sammlung gekapselt
58
     * werden. So, dass sie zum Beispiel eine eigene Klasse bilden
59
     * (sinnvoll bei Datenbank Funktionen)
60
     *
61
     * @category   CMS
62
     * @package    Weban_Shop
63
     * @author     Markus Niewerth 	<markus@weban.de>
64
     * @author     Lars Tiefland 	<tiefland@weban.de>
65
     * @copyright  1997-2007 Webagentur Niewerth
66
     * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
67
     * @link       http://server2/intranet/3_0.txt
68
     * @see        Functions
69
     * @since      Class available since Release 1.1
70
     */
71
 
72
    class Weban_Shop
73
    {
74
 
75
        // {{{ properties
76
 
77
        /**
78
         * The Shops ID number.
79
         *
80
         * Its a very important ID, cause the
81
         * ID is saved in any userdefined data-
82
         * base entry like articles a.s.o.
83
         *
84
         * @var int
85
         */
86
        var $shopsId;
87
 
88
        /**
89
         * The Shop language.
90
         *
91
         * The Base language is DE. Note that this
92
         * value could be mixed! But stadard is DE
93
         *
94
         * @var 	array
95
         */
96
        var $language;
97
 
98
        /**
99
         * The Functions Object
100
         *
101
         * A refference to the Functions Object
102
         * constructed with this Base Class.
103
         * ote that you have to call to the
104
         * object with the -> operator, like:
105
         * $Weban_Shop->Functions->Method()
106
         *
107
         * @var object
108
         * @var object
109
         */
110
        var $Functions;
111
 
112
        var $Rapid_Templates;
113
 
114
        var $Basket;
115
 
116
        var $Error;
117
 
118
        // }}}
119
        // {{{ Weban_Shop()
120
 
121
        /**
122
         * Base Constructor
123
         *
124
         * @param 	object
125
         * @param 	object
126
         * @return	Weban_Shop
127
         */
128
        function Weban_Shop( $shopsId = 1, $language = __BASELANGUAGE__ )
129
        {
130
 
131
            $this->shopsId = $shopsId;
132
            $this->language = $language;
133
 
134
            // Construct the Functions Object
135
            $this->Functions = &new Functions( $this->shopsId, $this->language );
136
            $this->Rapid_Templates = &new Rapid_Templates( $this->shopsId,
137
                __TEMPLATE_EXTENSION__, '' );
138
            $this->Basket = &new Basket( $this->shopsId, __TEMPLATE_EXTENSION__ );
139
            $this->Error = &new Error( $this->shopsId, $this->language );
140
        }
141
        // }}}
142
 
143
        function showBasket( $templateRoot )
144
        {
145
            $template = loadTemplates( $templateRoot );
146
            $buffer = array();
147
            $content = array();
148
 
149
            $basketItems = getBasketItems();
150
 
151
            if ( $basketItems == array() )
152
            {
153
                echo templateContent( array(), $template["basketEmpty"] );
154
                echo $this->Rapid_Templates->rapidEngine();
155
            }
156
            else
157
            {
158
                foreach ( $basketItems as $elem )
159
                {
160
                    if ( $elem["Father"] != -3 )
161
                    {
162
                        $addonItems = array();
163
 
164
                        foreach ( getAddOnItems($elem["ID"]) as $addonItem )
165
                        {
166
                            templateContent( $addOnItem, $template["addOnItemImage"] );
167
                        }
168
                        $elem[MengeAdd] = $elem[Menge] + 1;
169
                        $elem[MengeSub] = $elem[Menge] - 1;
170
 
171
                        $buffer[] = templateContent( $elem, $template["basketItem"] );
172
                    }
173
                }
174
 
175
                $content["basketItems"] = implode( "", $buffer );
176
 
177
                // Gesamtsumme ausgeben
178
                $content["basketSumme"] = templateContent( array("title" =>
179
                    "Gesamtsumme (inkl. 19 % MwSt.: " . numberFormat(getBasketSummeMWST()) .
180
                    "&nbsp;&euro;)", "summe" => numberFormat(getBasketSumme()) . "&nbsp;&euro;"),
181
                    $template["msg"] );
182
 
183
                unset( $msg );
184
 
185
                // Versandoptionen lesen und ausgeben
186
                $versandarten = array();
187
 
188
                foreach ( getVersandItems() as $vItem )
189
                {
190
                    $vItem_Beschreibung = $vItem[beschr];
191
                    $vItem[preis] = numberFormat( $vItem[preis] ) . "&euro;";
192
                    $versandarten[] = templateContent( $vItem, $template[versandItem] );
193
                }
194
 
195
                if ( $_SESSION[SHOP][Lieferadresse] == "true" )
196
                {
197
                    $Land = $_SESSION[SHOP][buy][Persdata][liefer_Land];
198
                }
199
                else
200
                {
201
                    $Land = $_SESSION[SHOP][buy][Persdata][Land];
202
                }
203
 
204
                $msg[title] = "M&ouml;gliche Versandarten f&uuml;r " . getCountryByID( $Land ) .
205
                    " (inkl. 19% MwSt.):<br>";
206
                $msg[Versand] = "<ul>" . implode( "", $versandarten ) . "</ul>";
207
                if ( count($versandarten) == 1 )
208
                {
209
                    $msg[Versand] .= "<p>" . $vItem_Beschreibung . "</p>";
210
                }
211
                $content["basketVersand"] = templateContent( $msg, $template["msg"] );
212
                unset( $msg );
213
 
214
                echo templateContent( $content, $template["basketContainer"] );
215
 
216
            }
217
        }
218
 
219
        function getNavTree( $root = "root", $rootInfo = false )
220
        {
221
            static $getNavTreeBuffer = array();
222
 
223
            if ( $getNavTreeBuffer != array() )
224
            {
225
                $buffer = $getNavTreeBuffer;
226
            }
227
            else
228
            {
229
                $query = "
230
				select
231
					directory.*,
232
					if (directory.Father = -1, 'root', directory.Father) as Father,
233
					Herstellerkatalog.Logo1 as Logo
234
				from
235
					directory
236
				left join
237
					Herstellerkatalog
238
				on
239
					Herstellerkatalog.Bezeichnung = directory.Name
240
				where
241
					directory.status=0
242
				and
243
					directory.Artikelstamm=0
244
				and
245
					directory.Language= '" . $_SESSION['INI']['language'] . "'
246
				order by
247
					directory.Kennung
248
			";
249
 
250
                $buffer = array();
251
                $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
252
                    "<hr>$query<hr>" );
253
                while ( $zeile = mysql_fetch_assoc($result) )
254
                {
255
                    $buffer[$zeile['ID']] = $zeile;
256
                }
257
 
258
                foreach ( array_keys($buffer) as $id )
259
                {
260
                    if ( !$buffer[$id]['childNodes'] )
261
                    {
262
                        $buffer[$id]['childNodes'] = array();
263
                    }
264
                    $buffer[$buffer[$id]['Father']]['childNodes'][] = &$buffer[$id];
265
                }
266
            }
267
 
268
            $getNavTreeBuffer = $buffer;
269
 
270
            if ( $rootInfo == true )
271
            {
272
                return $buffer[$root];
273
            }
274
            else
275
            {
276
                return $buffer[$root]['childNodes'];
277
            }
278
        }
279
 
280
        function getPath( $root )
281
        {
282
            static $level = 0;
283
            $level++;
284
 
285
            if ( $root > 0 )
286
            {
287
                $query = "
288
				select
289
					*
290
				from
291
					directory
292
				where
293
					ID = $root
294
				and
295
					language= '" . $_SESSION['INI']['language'] . "'
296
				";
297
                $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
298
                    "<hr>" . $query );
299
                $zeile = mysql_fetch_assoc( $result );
300
 
301
                // Bilder um Pfad und Tag erweitern
302
                foreach ( array("", "2") as $i )
303
                {
304
                    if ( $zeile["bild_url" . $i] )
305
                    {
306
                        $_tmp = $zeile["bild_url" . $i];
307
                        $zeile["image_tag" . $i] = sprintf( __IMAGE_POPUP_TAG__, $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
308
                            $i] . $zeile["bild_url" . $i], $zeile["bild_url" . $i], $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
309
                            $i] . "kl/" . $_tmp );
310
                        $zeile["bild_url" . $i] = "<img src=" . $_SESSION['INI']['itemContainerKorrektur']["imagePath" .
311
                            $i] . $_tmp . " >";
312
                    }
313
                    else
314
                    {
315
                        $zeile["bild_url" . $i] = "";
316
                    }
317
                }
318
 
319
 
320
                $path = $this->getPath( $zeile['Father'] );
321
 
322
                $path[] = $zeile;
323
 
324
                $level--;
325
 
326
                if ( $level == 0 )
327
                {
328
                    foreach ( $path as $p )
329
                    {
330
                        if ( $p['status'] == 1 )
331
                        {
332
                            $path = array();
333
                        }
334
                    }
335
                }
336
 
337
                return $path;
338
            }
339
            else
340
            {
341
                $level--;
342
                return array();
343
            }
344
        }
345
 
346
        function _navigation( $root = "root" )
347
        {
348
            $treebuffer = $this->getNavTree( $root );
349
            if ( $treebuffer == array() )
350
            {
351
                return;
352
            }
353
 
354
            $treebufferCount = count( $treebuffer ) - 1;
355
 
356
            foreach ( $treebuffer as $counter => $zeile )
357
            {
358
                /* ######################################################################## */
359
                /* Link entsprechend der Alias-Definition generieren.						*/
360
                /* ######################################################################## */
361
                if ( $_SESSION['INI']['alias'] == 0 )
362
                {
363
                    // dirLink
364
                    $zeile['dirLink'] = "?navigation=" . $zeile['ID'];
365
                }
366
                else
367
                {
368
                    // Pfad ermitteln
369
                    $buffer = array();
370
                    foreach ( $this->getPath($zeile['ID']) as $elem )
371
                    {
372
                        $buffer[] = preg_replace( "/[\W]+/", "", $elem['ID'] . "_" . $elem['Name'] );
373
                    }
374
 
375
                    // dirLink
376
                    $zeile['dirLink'] = "/" . implode( "/", $buffer ) . "/";
377
                }
378
 
379
                /* ######################################################################## */
380
                /* Ausgabe der Unterverzeichnisse											*/
381
                /* ######################################################################## */
382
 
383
                $classes = array();
384
                $classes[] = "normal";
385
                if ( $_SESSION['navigation']['status'][$zeile['ID']] == true )
386
                {
387
                    $classes[] = "active";
388
                }
389
 
390
 
391
                echo "<div class=\"" . implode( " ", $classes ) . "\">";
392
 
393
                echo "<a href=\"" . $zeile['dirLink'] . "\">";
394
                echo $zeile['Name'];
395
                echo "</a>";
396
 
397
                if ( ($_SESSION['navigation']['status'][$zeile['ID']] == true) && ($zeile['Father'] ==
398
                    "root") )
399
                {
400
                    $this->navigation( $zeile['ID'] );
401
                }
402
 
403
                echo "</div>\n";
404
            }
405
        }
406
 
407
        function navigation( $root )
408
        {
409
            ob_start();
410
            {
411
                echo "<div class=nav>";
412
 
413
                if ( $_REQUEST['staticNav'] == "true" )
414
                {
415
                    include ( $_SESSION['INI']['staticNav'] );
416
                }
417
                else
418
                {
419
                    $this->_navigation( $root );
420
                }
421
 
422
                echo "</div>";
423
            }
424
            $_ret = ob_get_contents();
425
            ob_end_clean();
426
            return $_ret;
427
        }
428
 
429
 
430
        function shopPosition( $item = "" )
431
        {
432
            $return = null;
433
            $buffer = array();
434
 
435
            foreach ( getPath($_SESSION['navigation']['position']) as $dir )
436
            {
437
                if ( $dir['Father'] > 0 )
438
                {
439
                    //echo " / ";
440
                    $return = $return . $_SESSION['INI']['shopPosition']['imageTrennerSrc'];
441
                }
442
 
443
                $buffer[] = preg_replace( "/[\W]+/", "", $dir['ID'] . "_" . $dir['Name'] );
444
 
445
                if ( $_SESSION['INI']['alias'] == 0 )
446
                {
447
                    $link = "?navigation=" . $dir['ID'];
448
                }
449
                else
450
                {
451
                    $link = "/" . implode( "/", $buffer ) . "/";
452
                }
453
 
454
                if ( $dir['Artikelstamm'] == 0 )
455
                {
456
                    $return = $return . "<a href=\"$link\">" . $dir['Name'] . "</a>";
457
                }
458
                else
459
                {
460
                    $return = $return . "<a href=\"$link\">" . $dir['Name'] . "</a>";
461
                }
462
            }
463
            if ( is_array($item) )
464
            {
465
                //echo " / ";
466
                $return = $return . "<a href=\"" . $item['itemLink'] . "\">" . $item['kurzbezeichnung'] .
467
                    "</a>";
468
            }
469
            return $return;
470
        }
471
        function showError( $msg = "!" )
472
        {
473
            echo "<span class=\"error\">" . nl2br( $msg ) . "</span>";
474
        }
475
 
476
        function getVersandItems()
477
        {
478
            if ( $_SESSION['SHOP']['Lieferadresse'] == "true" )
479
            {
480
                $Land = $_SESSION['SHOP']['buy']['Persdata']['liefer_Land'];
481
            }
482
            else
483
            {
484
                $Land = $_SESSION['SHOP']['buy']['Persdata']['Land'];
485
            }
486
 
487
            if ( !$Land )
488
            {
489
                $_SESSION['SHOP']['buy']['Persdata']['Land'] = 1;
490
                $Land = $_SESSION['SHOP']['buy']['Persdata']['Land'];
491
            }
492
 
493
            $query = "
494
			SELECT
495
				ID,
496
				kurzbezeichnung as kurz,
497
				langbezeichnung	as lang,
498
				beschreibung as beschr,
499
				preis1 as preis,
500
				1 as Versand
501
			FROM
502
				artikel
503
			WHERE
504
				Father = -3
505
			AND
506
				Language = 'DE'
507
			AND
508
				Lieferstatus & " . $Land . " = " . $Land . "
509
			AND
510
				status = " . $_SESSION['INI']['shops_ID'] . "
511
		";
512
 
513
 
514
            if ( $_SESSION['INI']['versandByWeight'] )
515
            {
516
                $query .= "
517
			AND
518
			(
519
				(" . $this->Basket->getBasketGewicht() .
520
                    " between preis_neu1 and preis_neu2)
521
				OR
522
				( preis_neu1=preis_neu2)
523
			)
524
			";
525
            }
526
            else
527
            {
528
                $query .= "
529
			AND
530
			(
531
				(" . $this->Basket->getBasketSumme( true ) .
532
                    " between preis_neu3 and preis_neu4)
533
				OR
534
				( preis_neu3 = preis_neu4)
535
			)
536
			";
537
            }
538
            $query .= " order by Rang asc";
539
 
540
            $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
541
                pre($query, true) );
542
            $buffer = array();
543
            while ( $zeile = mysql_fetch_assoc($result) )
544
            {
545
                $buffer[] = $zeile;
546
            }
547
            return $buffer;
548
        }
549
 
550
        function getVersandItem( $gewicht, $preis )
551
        {
552
            $query = "
553
		SELECT
554
			ID,
555
			kurzbezeichnung as kurz,
556
			langbezeichnung	as lang,
557
			beschreibung as beschr,
558
			preis1 as preis,
559
			1 as Versand
560
		FROM
561
			artikel
562
		WHERE
563
			Father = -3
564
		AND
565
			Language = 'DE'
566
		AND
567
			Lieferstatus & 1 = 1
568
		AND
569
			status = " . $_SESSION['INI']['shops_ID'] . "
570
		AND
571
			'" . $gewicht . "' between preis_neu1 and preis_neu2
572
		AND
573
			(
574
				('" . $preis . "' between preis_neu3 and preis_neu4)
575
				or
576
				(preis_neu3 = preis_neu4)
577
			)
578
		AND
579
			kurzbezeichnung like '%Nachnahme%'
580
		ORDER BY
581
			preis1 ASC
582
		LIMIT 1
583
		";
584
 
585
 
586
            $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() .
587
                pre($query, true) );
588
            if ( $zeile = mysql_fetch_assoc($result) )
589
            {
590
                return $zeile;
591
            }
592
            else
593
            {
594
                return false;
595
            }
596
        }
597
 
598
        function getSelectedVersandItem()
599
        {
600
            foreach ( $_SESSION['SHOP']['BASKET'] as $id => $item )
601
            {
602
                if ( $item[$opt['ID']]['Versand'] )
603
                {
604
                    return $id;
605
                }
606
            }
607
            return false;
608
        }
609
        // Formatiert nicht gesetzte argumente mit
610
        // einem Standard auffüller. Und setzt für
611
        // alles Umbrüche.
612
        function formate( $mixed, $fomate = 'getSubDirs' )
613
        {
614
            switch ( $formate )
615
            {
616
                case 'getSubDirs':
617
                default:
618
                    foreach ( array_keys($mixed) as $key )
619
                    {
620
                        if ( $key == "Beschreibung" )
621
                        {
622
                            $mixed[$key] = empty( $mixed[$key] ) ? $_SESSION['INI']['formateFiller'] :
623
                                nl2br( $mixed[$key] );
624
                        }
625
                    }
626
                    break;
627
            }
628
        }
629
 
630
        function subdir( $dirId )
631
        {
632
            $this->counter( $dirId, 'directory', $_SESSION['INI']['shops_ID'] ); // Marked for replace
633
            $template = loadTemplates( $_SESSION['INI']['TEMPLATE']['subDir'] ); // Marked for replace
634
 
635
            // Unterverzeichnisse + Templates auslesen & ausgeben
636
            $data = array();
637
 
638
            if ( $_SESSION['INI']['getSubDirs'] )
639
            {
640
 
641
                $counter = 0;
642
                $subdirs = getSubDirs( $dirId );
643
                $subdirlast = sizeof( $subdirs ) - 1;
644
 
645
                // Shop Position ausgeben
646
                /**
647
                 * echo "<div id=shopPosition>";
648
                 * echo $this->shopPosition($dirId, true);
649
                 * echo "</div>";
650
                 */
651
 
652
                // Subdirs durchlaufen
653
                foreach ( $subdirs as $subDir ) // Marked for replace
654
 
655
                {
656
                    $this->formate( $subDir, 'getSubDirs' );
657
 
658
                    if ( $_SESSION['INI']['alias'] == 0 )
659
                    {
660
                        // dirLink
661
                        $subDir['dirLink'] = "?navigation=" . $subDir['ID'];
662
                    }
663
                    else
664
                    {
665
                        // Pfad ermitteln
666
                        $buffer = array();
667
                        foreach ( getPath($subDir['ID']) as $elem ) // Marked for replace
668
 
669
                        {
670
                            $buffer[] = preg_replace( "/[\W]+/", "", $elem['ID'] . "_" . $elem['Name'] );
671
                        }
672
 
673
                        // dirLink
674
                        $subDir['dirLink'] = "/" . implode( "/", $buffer ) . "/";
675
                    }
676
 
677
                    $subDir['imageSrcClosed'] = "<img src=" . $_SESSION['INI']['navigation']['imageSrcClosed'] .
678
                        ">";
679
 
680
                    $data['subDirs'] .= templateContent( $subDir, $template['subDir'] );
681
 
682
                    if ( $counter != $subdirlast )
683
                    {
684
                        $data['subDirs'] .= $_SESSION['INI']['subdir']['seperator'];
685
                    }
686
 
687
                    $counter++;
688
                }
689
                $prepare = array( "shopPosition" => $data['subDirs'] );
690
 
691
 
692
                $data['subDirs'] = templateContent( $prepare, $template['subDirNavContainer'] );
693
            }
694
            // $data['subDirs'].=$this->Rapid_Templates->rapidEngine('templates/subdir_new/subdir', $subDir, true);
695
 
696
            if ( count($data) > 0 && strtolower($_SESSION['INI']['shopPosition']['position']) ==
697
                'top' )
698
            {
699
                echo templateContent( $data, $template['subDirContainer'] ); // Marked for replace
700
            }
701
 
702
            // Verzeichnistemplate auslesen & ausgeben
703
            $dirInfo = array_pop( $this->getPath($dirId) );
704
            $dirInfo['PATH'] = $this->shopPosition( $dirId, true );
705
            $dirInfo['TopText'] = "Ordner";
706
 
707
            echo templateContent( $dirInfo, $template['subDirHead'] ); // Marked for replace
708
 
709
            if ( $_GET["hersteller"] )
710
            {
711
                $cond = "kurzbezeichnung like '" . $_GET["hersteller"] . "%' ";
712
            }
713
            else
714
            {
715
                $cond = 1;
716
            }
717
 
718
            switch ( $_REQUEST['sort'] )
719
            {
720
                case "asc":
721
                    $items = getItems( $dirId, "artikel.preis" . $_SESSION['INI']['indexPreis'] .
722
                        " asc", $cond ); // Marked for replace
723
                    break;
724
                case "desc":
725
                    $items = getItems( $dirId, "artikel.preis" . $_SESSION['INI']['indexPreis'] .
726
                        " desc", $cond ); // Marked for replace
727
                    break;
728
                default:
729
                    $items = getItems( $dirId, "artikel.kurzbezeichnung", $cond ); // Marked for replace
730
                    break;
731
            }
732
            if ( count($data) > 0 && strtolower($_SESSION['INI']['shopPosition']['position']) ==
733
                'bottom' )
734
            {
735
                echo templateContent( $data, $template['subDirContainer'] ); // Marked for replace
736
            }
737
            $sort = array();
738
 
739
            // Herstellerauswahl erstellen
740
            // Wenn mehr als 1 Hersteller ... Auswahlliste ausgeben
741
            $hersteller = getItemsHersteller( $dirId ); // Marked for replace
742
            if ( count($hersteller) > 1 )
743
            {
744
                $herstellerBuffer = "";
745
                foreach ( $hersteller as $elem )
746
                {
747
                    if ( $elem["Bezeichnung"] == $_GET["hersteller"] )
748
                    {
749
                        $elem["selected"] = " selected";
750
                    }
751
                    $herstellerBuffer .= templateContent( $elem, $template["herstellerOption"] ); // Marked for replace
752
                }
753
 
754
                $sort["herstellerSelect"] = templateContent( array_merge($_GET, array("herstellerListe" =>
755
                    $herstellerBuffer)), $template["herstellerSelect"] );
756
            }
757
 
758
            // Sort-Buttons ausgeben falls gen�gend Items vorhanden
759
            if ( count($items) > $_SESSION['INI']['subDirSortMin'] )
760
            {
761
                switch ( $_GET["sort"] )
762
                {
763
                    case "asc":
764
                        $data = array( "asc" => " selected" );
765
                        break;
766
                    case "desc":
767
                        $data = array( "desc" => " selected" );
768
                        break;
769
                    default:
770
                        break;
771
                }
772
 
773
                if ( $_SESSION['INI']['preisSort'] )
774
                {
775
                    $sort["preisSort"] = templateContent( $data, $template["preisSort"] );
776
                }
777
                else
778
                {
779
                    $sort["preisSort"] = null;
780
                }
781
            } // Marked for replace
782
 
783
 
784
            if ( $_SESSION['INI']['subDirSort'] )
785
            {
786
                echo templateContent( $sort, $template['subDirSort'] ); // Marked for replace
787
            }
788
 
789
            echo "<div style=\"clear:both\"></div>";
790
 
791
            // Artikel und Artikelst�mme auslesen und vereinigen
792
            // getItemContainers: Artikelst�mme als Artikel maskieren
793
            // $items beinhaltet zu diesem Zeitpunkt die Artikel des Unterverzeichnisses
794
            $items = array_merge( getItemContainers($dirId), // Marked for replace
795
                $items );
796
 
797
            // Artikel ausgeben
798
            foreach ( $items as $item )
799
            {
800
                $item['Lieferstatus'] = templateContent( $item, $template["lieferstatus" . $item['LieferstatusValue']] );
801
 
802
                if ( $item['billigerGesehen'] )
803
                {
804
                    $item['billigerGesehen'] = templateContent( $item, $template['billigerGesehen'] );
805
                }
806
 
807
                if ( $item['Artikelstamm'] == 0 )
808
                {
809
                    echo templateContent( $item, $template['item'] );
810
                }
811
                else
812
                {
813
                    echo templateContent( $item, $template['itemContainer'] );
814
                }
815
            }
816
        }
817
 
818
        function counter( $ID, $typ, $shops_ID )
819
        {
820
            $query = array( "update" => "update
821
								counter
822
							set
823
								impressionCounter = impressionCounter + 1
824
							where
825
								ID = $ID
826
							and
827
								typ = '$typ'
828
							and
829
								shops_ID = $shops_ID
830
							and
831
								date = date_format(NOW(),'%Y-%m-%d')", "insert" => "insert into
832
								counter
833
							values
834
							(
835
								$ID,
836
								$shops_ID,
837
								'$typ',
838
								date_format(NOW(),'%Y-%m-%d'),
839
								0,
840
								0,
841
 
842
							)
843
							" );
844
 
845
            mysql_query( $query['insert'] );
846
            mysql_query( $query['update'] );
847
        }
848
 
849
    function createMailOrderText()
850
    {
851
        //$ret = getAbschlag();
852
        $text = "\nMenge   Art-Nr. Artikelname                      Einzelpreis    Gesamtpreis\n___________________________________________________________________________\n";
853
 
854
        /*
855
        $query = "
856
        select
857
        *
858
        from
859
        artikel
860
        where
861
        (
862
        ID = " . implode( " or ID = ", array_keys($_SESSION['SHOP']['BASKET']) ) .
863
        "
864
        )
865
        and
866
        Language='" . $_SESSION['INI']['language'] . "'
867
        order by
868
        Father desc,Kennung
869
        ";
870
        $result = mysql_query( $query ) or mail( "niewerth@weban.de",
871
        "Fehler in createMailOrderText.php", mysql_errno() . ": " .
872
        mysql_error() . "<hr>$query<hr>", "from: hausshop-24.de" );
873
        */
874
 
875
        foreach ( $_SESSION['SHOP']['BASKET'] as $basketItemID => $elem )
876
 		{
877
 
878
            //while ( $zeile = @mysql_fetch_array($result) )
879
            //{
880
            //$zeile = itemKorrektur( $elem );
881
 
882
            $zeile = getItem( $elem['ID'] );
883
 
884
            if ( stristr( $zeile['kurzbezeichnung'], 'Nachnahme' ) )
885
            {
886
                $nachnamegebuehr = "\n\r + Nachnahmegebühr, welche vom Auslieferer erhoben wird.\n\r";
887
            }
888
 
889
            if ( $elem['Versand'] )
890
            {
891
                $text = $text . "\n1     x Versand: " . str_pad( $zeile['kurzbezeichnung'],
892
                    37 ) . str_pad( number_format( $zeile['preis'], 2, ',',
893
                    '.' ), 14, " ", STR_PAD_LEFT ) . " EUR";
894
                if ( is_numeric( $zeile["preis2"] ) && $zeile["preis2"] > 0 )
895
                {
896
                    $text = $text . "\n" . str_pad( "1", 5 ) . " x " .
897
                        str_pad( "Zahlungssystemaufschlag", 31 ) . " " .
898
                        str_pad( numberFormat( getAufschlag() ), 6, " ",
899
                        STR_PAD_LEFT ) . " Euro" . str_pad( numberFormat( getAufschlag
900
                        () ), 10, " ", STR_PAD_LEFT ) . " Euro\n";
901
                }
902
            }
903
            else
904
            {
905
                /* START Artikeloptionen zusammenstellen */
906
                if ( is_array( $elem['option'] ) )
907
                {
908
                    $query_Feature_options =
909
                        "select * from Feature_options where ID = " .
910
                        implode( " or ID = ", $elem['option'] );
911
                    $result_Feature_options = mysql_query( $query_Feature_options ) or
912
                        mail( "niewerth@weban.de",
913
                        "Fehler2 in createMailOrderText.php", mysql_errno() .
914
                        ": " . mysql_error() . "<hr>$query<hr>",
915
                        "from: it-styles.de" );
916
 
917
 
918
                    while ( $zeile_Feature_options = mysql_fetch_array( $result_Feature_options ) )
919
                    {
920
                        $Feature_options[] = $zeile_Feature_options['Value'];
921
                    }
922
                    $optionen = " (" . implode( ", ", $Feature_options ) .
923
                        ")";
924
                    unset( $Feature_options );
925
                }
926
                else
927
                {
928
                    $optionen = "";
929
                }
930
 
931
                $artikeltext = $zeile['kennung'] . " " . $zeile['kurzbezeichnung'] .
932
                    " " . $optionen;
933
 
934
 
935
                // ME: bei Stempeln die Detailinfos anzeigen
936
                if ( $elem['ct_zeilen'] )
937
                {
938
                    foreach ( $elem as $k => $v )
939
                    {
940
                        if ( stristr( $k, "ct_" ) )
941
                        {
942
                            $opt[$k] = mysql_real_escape_string( $v );
943
                        }
944
                    }
945
                    $artikeltext .= buildCustomTextEmail( $opt );
946
                }
947
 
948
 
949
 
950
                /* STOP Artikeloptionen zusammenstellen */
951
                $text .= "\n" . str_pad( $elem['Menge'], 5 ) . " x " .
952
                    str_pad( $artikeltext, 40 ) . " " . str_pad( number_format
953
                    ( $zeile['preis'], 2, ",", "." ), 6, " ", STR_PAD_LEFT ) .
954
                    " EUR" . str_pad( number_format( $elem['Menge'] * $zeile['preis'],
955
                    2, ",", "." ), 10, " ", STR_PAD_LEFT ) . " EUR";
956
            }
957
        }
958
        $rabatt = getBasketSumme( true ) * -1 * $ret["abschlag"] / 100;
959
        /*$text .= "
960
                    \n1     x " . str_pad( $ret["abschlag"] .
961
            "% Skonto auf Warenwert ", 37 ) . str_pad( number_format( $rabatt,
962
            2, ',', '.' ), 14, " ", STR_PAD_LEFT ) . " EUR
963
                ";
964
        */
965
        $text = $text . "\n---------------------------------------------------------------------------\nGesamtpreis: " .
966
            str_pad( number_Format( getBasketSumme(), 2, ',', '.' ), 58, " ",
967
            STR_PAD_LEFT ) . " EUR " . $nachnamegebuehr . " \nDieser Betrag enthält 19 % MwSt.:" .
968
            str_pad( number_Format( getBasketSummeMWST(), 2, ',', '.' ), 61,
969
            " ", STR_PAD_LEFT ) . " EUR";
970
 
971
 
972
        return $text;
973
 
974
    }
975
 
976
        // Ist ausgelagert worden in ein eigenes Modul
977
        /**
978
         * Erstellt ein Bild anhand eines Codes, der auf
979
         * eine Email refferenziert.
980
         *
981
         * @deprecated	Please use the Module Email_Safe
982
         * @since 		26.06.2007
983
         */
984
        function createEmailImage()
985
        {
986
            $code = $_SESSION['emailAddr'][$_GET['mx']]; //  Weban_Shop::translate_email_code($_SESSION['emailRegister'],$_GET['mx']);
987
            header( "Content-type: " . __EMAIL_IMAGE_CONTENT_TYPE__ );
988
 
989
            $cp_im = imagecreatefromjpeg( __IMAGE_EMAIL_INPUT__ );
990
            $white = ImageColorAllocate( $cp_im, 255, 255, 255 );
991
            $black = ImageColorAllocate( $cp_im, 0, 0, 0 );
992
            imagettftext( $cp_im, 8, 0, 21, 28, $black, __GD_TTF_FONT__, "<" . $code .
993
                ">" );
994
 
995
            imagepng( $cp_im );
996
            imagedestroy( $cp_im );
997
 
998
        }
999
 
1000
        /**
1001
         * Erzeugt ein Email Register
1002
         * "Codes, Variablen und Emails"
1003
         *
1004
         * @deprecated	Please use the Module Email_Safe
1005
         * @since 		26.06.2007
1006
         */
1007
        function create_email_register( $emails )
1008
        {
1009
            foreach ( $emails as $email )
1010
            {
1011
                $_SESSION['emailAddr'][md5( $email )] = $email;
1012
                $_SESSION['emailRegister'][$email] = md5( $email );
1013
            }
1014
        }
1015
        /**
1016
         * Übersetzt einen MD5 Code in eine Email Adresse
1017
         *
1018
         * @deprecated	Please use the Module Email_Safe
1019
         * @since 		26.06.2007
1020
         */
1021
        function translate_email_code( $email, $emArr )
1022
        {
1023
            return $emArr[$email];
1024
        }
1025
    }
1026
    // }}}
1027
 
1028
    /*
1029
    * Local variables:
1030
    * tab-width: 4
1031
    * c-basic-offset: 4
1032
    * c-hanging-comment-ender-p: nil
1033
    * End:
1034
    */
1035
?>