Subversion-Projekte lars-tiefland.content-management

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    /**
4
     * @package   Kein Projekt geladen
5
     * @author     <>
6
     * @copyright 2009
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 3980 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Kein Projekt geladen
16
     * @author     <>
17
     * @copyright 2009
18
     */
19
 
20
    define( "FROM_BESTELLUNG", true );
21
    // SVN: $Id: bestellung_formular.php 3980 2011-10-10 06:53:08Z erling $
22
 
23
    if ( stristr( $_SERVER["HTTP_USER_AGENT"], "ipad" ) || stristr( $_SERVER["HTTP_USER_AGENT"],
24
        "iphone" ) )
25
    {
26
        $GLOBALS["ui"]->assign( "ipad", true );
27
    }
28
 
29
    require_once "includes/bestellungen/system/artikelDatabase.php";
30
    require_once "../Online-Shop/connect2.php";
31
    require_once "../includes/system/functions.lagerwirtschaft.php"; //PL
32
 
33
    $preise_anzeigen = 1;
34
    $preise_nicht_drucken = 0;
35
    $d_colspan = "";
36
 
37
    if ( isset( $web_rechte[modul_name][tool_name]["preise_anzeigen"] ) )
38
    {
39
        if ( !isset( $user_rechte[modul_name][tool_name]["preise_anzeigen"] ) )
40
        {
41
            // "<br>für bestimmte user preis verbergen";
42
            $preise_anzeigen = 0;
43
        }
44
    }
45
    if ( isset( $_POST["Bestellung"] ) )
46
    {
47
        $b_id = $_POST["Bestellung"];
48
    }
49
    else
50
    {
51
        $b_id = $_GET["Bestellung"];
52
    }
53
    bestellung_puffern( $b_id );
54
 
55
 
56
 
57
    //weban_debug(isset( $web_rechte["Warenwirtschaft"]["bestellung"]["adressbuch"] ));
58
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["adressbuch"] ) )
59
    {
60
        $sql = "SELECT
61
                ship_addr_id,
62
                bill_addr_id
63
            FROM
64
                Bestellung AS b
65
            WHERE
66
                b.ID=$b_id
67
        ";
68
        $res = mysql_query( $sql );
69
        $row = mysql_fetch_assoc( $res );
70
        $bill_addr_id = $row["bill_addr_id"];
71
        $ship_addr_id = $row["ship_addr_id"];
72
        if ( $bill_addr_id )
73
        {
74
            $sql = "SELECT
75
                    Anrede,
76
                    Vorname,
77
                    Nachname AS Name1,
78
                    Firma AS Name2,
79
                    Strasse1 AS Strasse,
80
                    Str_Nr1 AS Hausnummer,
81
                    strasse2,
82
                    PLZ,
83
                    Ort AS ORT,
84
                    country AS Land,
85
                    comment
86
                FROM
87
                    adresse AS a
88
                JOIN
89
                    countries AS c
90
                ON
91
                    c.ID=a.Land
92
                WHERE
93
                    a.id = $bill_addr_id
94
            ";
95
            $res = mysql_query( $sql );
96
            $bill_addr = mysql_fetch_assoc( $res );
97
        }
98
        if ( $ship_addr_id )
99
        {
100
            $sql = "SELECT
101
                    Anrede AS liefer_Anrede,
102
                    Vorname AS liefer_Vorname,
103
                    Nachname AS liefer_Name,
104
                    Firma AS liefer_Firma,
105
                    Strasse1 AS liefer_Strasse,
106
                    Str_Nr1 AS liefer_Str_Nr,
107
                    strasse2 AS liefer_strasse2,
108
                    PLZ AS liefer_PLZ,
109
                    Ort AS liefer_Ort,
110
                    country AS liefer_Land,
111
                    comment AS liefer_comment
112
                FROM
113
                    adresse AS a
114
                JOIN
115
                    countries AS c
116
                ON
117
                    c.ID=a.Land
118
                WHERE
119
                    a.id = $ship_addr_id
120
            ";
121
            $res = mysql_query( $sql );
122
            $ship_addr = mysql_fetch_assoc( $res );
123
        }
124
    }
125
    $sql = "
126
            SELECT
127
                b.*,
128
				-- l.Status,
129
				-- l.user,
130
				-- l.passwd,
131
				l.Telefon,
132
				l.Fax,
133
				l.E_Mail,
134
    ";
135
    if ( !isset( $web_rechte["Warenwirtschaft"]["bestellung"]["adressbuch"] ) )
136
    {
137
        $sql .= "
138
				l.Anrede,
139
				l.Vorname,
140
				l.Name1,
141
				l.Name2,
142
				l.Strasse,
143
				l.Hausnummer,
144
				l.PLZ,
145
				l.ORT,
146
				l.Land,
147
				l.AP_Name,
148
				l.AP_Handy,
149
				l.AP_Bemerkung,
150
        ";
151
    }
152
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
153
    {
154
        $sql .= "
155
                c.locale,
156
        ";
157
    }
158
    if ( $bestellarten )
159
    {
160
        $sql .= "
161
                ba.name AS Bestellart,
162
        ";
163
    }
164
    $sql .= "
165
                s.Name AS shop,
166
                s.ID AS shops_ID,
167
                b.gesamtsumme_buffer
168
            FROM
169
				Bestellung AS b,
170
    ";
171
    if ( $bestellarten )
172
    {
173
        $sql .= "
174
                bestellart AS ba,
175
        ";
176
    }
177
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
178
    {
179
        $sql .= "
180
                currencies c,
181
        ";
182
    }
183
    $sql .= "
184
				Logins AS l,
185
                shops AS s
186
    ";
187
    $sql .= "
188
            WHERE
189
				b.ID = $Bestellung
190
            AND
191
				l.ID = b.Login
192
            AND
193
                s.ID = b.shops_ID
194
    ";
195
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["waehrung"] ) )
196
    {
197
        $sql .= "
198
            AND
199
                c.id=b.currency
200
        ";
201
    }
202
    if ( $bestellarten )
203
    {
204
        $sql .= "
205
            AND
206
                ba.ID=b.bestellart_id
207
        ";
208
    }
209
    $res = mysql_query( $sql );
210
    if ( !$res )
211
    {
212
        echo weban_debug( mysql_error() . "<br>$sql" );
213
    }
214
    $row = mysql_fetch_assoc( $res );
215
    $zeile = $row;
216
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["adressbuch"] ) )
217
    {
218
        $row = array_merge( $row, $bill_addr, $ship_addr );
219
    }
220
    /*if ( isset( $user_rechte["Warenwirtschaft"]["bestellung"]["fremd_id"] ) &&
221
    $zeile["fremd_id"] )
222
    {*/
223
    $d_colspan = "colspan=\"2\"";
224
    //}
225
    $row["kk_info"] = unserialize( $row["kk_info"] );
226
    $row["kk_summe"] = $row["gesamtsumme_buffer"] * 100;
227
    $daten["Bestellung"] = $row;
228
    $daten["Bestellung"]["artikel"] = array();
229
    $Userdata = $zeile;
230
    $bufferLand = $row["liefer_Land"];
231
    if ( empty( $bufferLand ) )
232
    {
233
        $bufferLand = $row["Land"];
234
    }
235
 
236
    $versandItems = getVersandItems( $row["shops_ID"], $row["Language"], $bufferLand );
237
 
238
    //var_dump($versandItems);
239
 
240
    if ( $versandItems != array() )
241
    {
242
        $daten["Versand"] = array();
243
        $daten["Versand"][] = "";
244
        foreach ( $versandItems as $versandOption )
245
        {
246
            $daten["Versand"][base64_encode( serialize( $versandOption ) )] =
247
                $versandOption["kurz"];
248
        }
249
    }
250
 
251
    $erstellt_am = datetime2human( $zeile["erstellt_am"] );
252
    $Datum = $erstellt_am["Datum"];
253
    $Zeit = $erstellt_am["Zeit"];
254
    $Username = $_SERVER["PHP_AUTH_USER"];
255
    $Username_text = $_SESSION["USERNAME"];
256
    $Auftragsnummer = $Bestellung;
257
    $Heute = date( "d.m.Y" );
258
    $jetzt = date( "H:i" );
259
 
260
    $BestellID = $row["ID"];
261
    $shops_ID = $row["shops_ID"];
262
    $Artikelliste = createOrderText( $BestellID, $shops_ID );
263
    $Artikelliste_html = createOrderText_html( $BestellID, $shops_ID );
264
    $Artikelliste_html_v2 = createOrderText_html_v2( $BestellID, $shops_ID );
265
    $Bestellwert_brutto = Bestellwert_brutto( $BestellID, $shops_ID );
266
 
267
    if ( $bestellart )
268
    {
269
        $query = "
270
            SELECT
271
                *
272
            FROM
273
                $settings_table
274
            WHERE
275
                bestellart_id=" . $zeile["bestellart_id"] . "
276
            AND
277
                shops_ID = $shops_ID
278
            ORDER BY
279
                Rang";
280
    }
281
    else
282
    {
283
        $query = "
284
            SELECT
285
                *
286
            FROM
287
                $settings_table
288
            WHERE
289
                shops_ID = $shops_ID
290
            ORDER BY
291
                Rang";
292
    }
293
 
294
    $result_w = mysql_query_logged( $query ) or die( mysql_errno() . ": " .
295
        mysql_error() . "<hr>$query<hr>" );
296
    if ( !mysql_num_rows( $result_w ) && $bestellart )
297
    {
298
        $query = "SELECT
299
                *
300
            FROM
301
                $settings_table
302
            WHERE
303
                shops_ID = $shops_ID
304
            AND
305
                bestellart_id=1
306
            ORDER BY
307
                Rang
308
        ";
309
        $result_w = mysql_query_logged( $query ) or die( mysql_errno() .
310
            ": " . mysql_error() . "<hr>$query<hr>" );
311
    }
312
    while ( $zeile_w = mysql_fetch_assoc( $result_w ) )
313
    {
314
        //        $web_settings[$zeile_w["shops_ID"]][$zeile_w["ID"]] = $zeile_w["Inhalt"];
315
        $buffer = $zeile_w["Inhalt"];
316
        $wsID = $zeile_w["ID"];
317
        if ( $wsID != 1000 )
318
        {
319
            if ( strpos( $buffer, '"' ) !== false )
320
            {
321
                $buffer = str_replace( '"', "***", $buffer );
322
            }
323
            @eval( "\$buffer=\"$buffer\";" );
324
            if ( strpos( $buffer, '***' ) !== false )
325
            {
326
 
327
                $buffer = str_replace( '***', '"', $buffer );
328
            }
329
        }
330
        $web_settings[$shops_ID][$wsID] = rawurlencode( $buffer );
331
    }
332
 
333
    $summe = 0;
334
    $runner = 0;
335
    $mahnungStatus = 0;
336
    $garantieStatus = 0;
337
    if ( isset( $web_rechte['Warenwirtschaft']['bestellung']['mahnungStatus'] ) &&
338
        $web_rechte['Warenwirtschaft']['bestellung']['mahnungStatus'] )
339
    {
340
        $mahnungStatus = 1;
341
    }
342
    if ( isset( $web_rechte['Warenwirtschaft']['bestellung']['garantieStatus'] ) &&
343
        $web_rechte['Warenwirtschaft']['bestellung']['garantieStatus'] )
344
    {
345
        $garantieStatus = 1;
346
    }
347
 
348
 
349
    $cmd_buttons = array( array( 'O', 'offen', 'status_red', 'artikelStatus',
350
 
351
 
352
        array( 'E', 'erledigt', 'status_green', 'artikelStatus', 0 ), array
353
        ( 'A', 'abgeschlossen', 'status_white', 'artikelStatus', 0 ),
354
        str_repeat( "&nbsp;", 3 ), array( 'S', 'schreiben', 'status_red',
355
        'rechnungStatus', 6 ), array( 'G', 'geschrieben', 'status_yellow',
356
        'rechnungStatus', 6 ), array( 'B', 'bezahlt', 'status_green',
357
        'rechnungStatus', 6 ), str_repeat( "&nbsp;", 3 ), array( 'S',
358
        'schreiben', 'status_yellow', 'lieferscheinStatus', 0 ), array( 'G',
359
        'geschrieben', 'status_green', 'lieferscheinStatus', 0 ), array( 'O',
360
        'offen', 'status_red', 'lieferscheinStatus', 0 ), str_repeat( "&nbsp;",
361
        3 ), array( '1', 'mahnung1', 'status_green', 'mahnungStatus', 0 ),
362
        array( '2', 'mahnung2', 'status_yellow', 'mahnungStatus', 0 ), array
363
        ( '3', 'mahnung3', 'status_red', 'mahnungStatus', 0 ), str_repeat( "&nbsp;",
364
        3 ), array( 'E', 'eingereicht', 'status_red', 'garantieStatus', 0 ),
365
        array( 'A', 'abgeschlossen', 'status_green', 'garantieStatus', 0 ), );
366
 
367
 
368
    $user_rechte[modul_name][tool_name]["artikelStatus"] = &$user_rechte[modul_name][tool_name]["status"];
369
 
370
 
371
    foreach ( array_keys( $cmd_buttons ) as $buttonIndex )
372
    {
373
        if ( ( !isset( $user_rechte[modul_name][tool_name][$cmd_buttons[$buttonIndex][3]] ) ) and
374
            ( is_array( $cmd_buttons[$buttonIndex] ) ) )
375
        {
376
            unset( $cmd_buttons[$buttonIndex] );
377
        }
378
    }
379
 
380
    if ( !isset( $filter["shops_ID"] ) )
381
    {
382
        $filter["shops_ID"] = "alle";
383
    }
384
    if ( $filter["shops_ID"] != "alle" )
385
    {
386
        $shopsIDaddOn = " and s.ID = " . $filter["shops_ID"];
387
    }
388
 
389
 
390
    // ME:
391
    //existiert das Feld 'option_eingabe'?
392
    $fields = mysql_list_fields( $webs['datenbank'], 'artikel_to_Bestellung' );
393
    $columns = mysql_num_fields( $fields );
394
    for ( $i = 0; $i < $columns; $i++ )
395
    {
396
        $field_array[] = mysql_field_name( $fields, $i );
397
    }
398
    if ( in_array( 'option_eingabe', $field_array ) )
399
    {
400
        $option_eingabe = "ab.option_eingabe,";
401
    }
402
 
403
    $fields = mysql_list_fields( $webs['datenbank'], 'artikel_to_Bestellung' );
404
    $columns = mysql_num_fields( $fields );
405
    for ( $i = 0; $i < $columns; $i++ )
406
    {
407
        $field_array[] = mysql_field_name( $fields, $i );
408
    }
409
    if ( in_array( 'option_eingabe', $field_array ) )
410
    {
411
        $option_eingabe = "ab.option_eingabe,";
412
    }
413
 
414
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["artikel_sortieren"] ) )
415
    {
416
 
417
 
418
        $sql_a = "SELECT
419
                ab.ID as ab_id,
420
                $option_eingabe
421
                ab.status,
422
                ab.Preis_pro_Stueck,
423
                ab.Menge,
424
                ab.Bezeichnung,
425
                ab.Bestellung,
426
                ab.rechnungstatus,
427
                ab.lieferscheinStatus,
428
                b.gesamtsumme_buffer,
429
                a.short_line_1,
430
        ";
431
        if ( $option_eingabe )
432
        {
433
            $sql_a .= $option_eingabe;
434
        }
435
        if ( $mahnungStatus )
436
        {
437
            $sql_a .= "ab.mahnungStatus,";
438
        }
439
        if ( $garantieStatus )
440
        {
441
            $sql_a .= "ab.garantieStatus,";
442
        }
443
        $sql_a .= "
444
                a.kennung,
445
                ab.artikel,
446
                ifnull(a.Father, 1) as Father,
447
                a.kurzbezeichnung,
448
                ab.Rang as ab_Rang
449
            FROM
450
                shops AS s
451
            JOIN
452
                artikel_to_Bestellung AS ab
453
            JOIN
454
                Bestellung AS b
455
            LEFT JOIN
456
                " . artikelDatabase( $daten["Bestellung"]["shops_ID"] ) .
457
            " AS a
458
            ON
459
                ab.artikel=a.ID
460
            AND
461
                a.language=b.Language
462
            WHERE
463
                b.ID = " . $daten["Bestellung"]["ID"] . "
464
            AND
465
                ab.Bestellung = b.ID
466
            AND
467
                s.ID = b.shops_ID
468
            ORDER BY
469
                Father desc,
470
                ab.Rang,
471
                a.Kennung
472
        ";
473
    }
474
    else
475
    {
476
        $sql_a = "SELECT
477
                ab.ID as ab_id,
478
                ab.status,
479
                ab.Preis_pro_Stueck,
480
                ab.Menge,
481
                ab.Bezeichnung,
482
                ab.Bestellung,
483
                ab.rechnungstatus,
484
                ab.lieferscheinStatus,
485
                b.gesamtsumme_buffer,
486
                a.short_line_1,
487
                b.language,
488
        ";
489
 
490
        if ( $option_eingabe )
491
        {
492
            $sql_a .= $option_eingabe;
493
        }
494
        if ( $mahnungStatus )
495
        {
496
            $sql_a .= "ab.mahnungStatus,";
497
        }
498
        if ( $garantieStatus )
499
        {
500
            $sql_a .= "ab.garantieStatus,";
501
        }
502
 
503
        $sql_a .= "
504
                a.kennung,
505
                $option_eingabe
506
                ab.artikel,
507
                ifnull(a.Father, 1) as Father,
508
                a.kurzbezeichnung,
509
                a.preis1,
510
                b.erstellt_am
511
            FROM
512
                shops AS s
513
            JOIN
514
                artikel_to_Bestellung AS ab
515
            JOIN
516
                Bestellung AS b
517
            LEFT JOIN
518
                " . artikelDatabase( $daten["Bestellung"]["shops_ID"] ) .
519
            " AS a
520
            ON
521
                ab.artikel=a.ID
522
            AND
523
                a.language=b.Language
524
            WHERE
525
                b.ID = " . $daten["Bestellung"]["ID"] . "
526
            AND
527
                ab.Bestellung = b.ID
528
            AND
529
                s.ID = b.shops_ID
530
            ORDER BY
531
                Father desc,
532
                a.Kennung
533
        ";
534
    }
535
 
536
    $itemList = array();
537
    unset( $Versand_Artikel );
538
    $res_a = mysql_query( $sql_a ) or die( mysql_errno() . ": " .
539
        mysql_error() . "<hr>" . nl2br( $sql_a ) . "<hr>" );
540
    $count = mysql_num_rows( $res_a );
541
    while ( $row_a = mysql_fetch_assoc( $res_a ) )
542
    {
543
        if ( $row_a['option_eingabe'] )
544
        {
545
            $row_a["option_eingabe"] = unserialize( $row_a['option_eingabe'] );
546
            $row_a["option_eingabe"] = buildCustomTextEmail( $row_a["option_eingabe"],
547
                1 );
548
        }
549
        $sql_h = "SELECT
550
                hk.Name
551
            FROM
552
                " . artikelDatabase( $daten["Bestellung"]["shops_ID"] ) .
553
            " a
554
            LEFT JOIN
555
                Herstellerkatalog AS hk
556
            ON
557
                hk.ID=a.Hersteller
558
            WHERE
559
                a.ID=" . $row_a["artikel"] . "
560
            AND
561
                a.languge='" . $row_a["language"] . "'
562
        ";
563
        $res_h = mysql_query( $sql_h );
564
        if ( $res_h )
565
        {
566
            $row_h = mysql_fetch_assoc( $res_h );
567
            $row_a["hersteller"] = $row_h["Name"];
568
        }
569
 
570
        $sql_e2 = "
571
            SHOW
572
                COLUMNS
573
            FROM
574
                eBay_Bestellung
575
        ";
576
        $res_e2 = mysql_query( $sql_e2 );
577
        if ( $res_e2 )
578
        {
579
            for ( $i = 0; $row_e2 = mysql_fetch_assoc( $res_e2 ); $i++ )
580
            {
581
                $felder_eb[$i] = $row_e2['Field'];
582
            }
583
 
584
            if ( in_array( 'a2b_ID', $felder_eb ) )
585
            {
586
                $sql_e = "SELECT
587
                        eb.eBay_Auktionen_ID AS ebay_art_id
588
                    FROM
589
                        eBay_Bestellung AS eb
590
                    JOIN
591
                        artikel_to_Bestellung AS a2b
592
                    ON
593
                        eb.a2b_ID = a2b.ID
594
                    WHERE
595
                        eb.a2b_ID=" . $row_a["ab_id"] . "
596
                    AND
597
                        a2b.artikel != 1
598
		        ";
599
 
600
                $res_e = mysql_query( $sql_e );
601
                if ( $res_e )
602
                {
603
                    $row_e = mysql_fetch_assoc( $res_e );
604
                    $row_a["ebay_art_id"] = $row_e["ebay_art_id"];
605
                }
606
            }
607
            else
608
            {
609
                $sql_e = "SELECT
610
                        eBay_Auktionen_ID AS ebay_art_id
611
                    FROM
612
                        eBay_Bestellung,
613
                        artikel_to_Bestellung
614
                    WHERE
615
                        Bestellung_ID =" . $row_a["Bestellung"] . "
616
                    AND
617
                        artikel_to_Bestellung.artikel != 1
618
                ";
619
 
620
                $res_e = mysql_query( $sql_e );
621
                if ( $res_e )
622
                {
623
                    $row_e = mysql_fetch_assoc( $res_e );
624
                    $row_a["ebay_art_id"] = $row_e["ebay_art_id"];
625
                }
626
            }
627
 
628
        }
629
 
630
 
631
 
632
        if ( $row_a["Father"] <= 0 || @stristr( $row_a["kurzbezeichnung"], $row_a["hersteller"] ) )
633
        {
634
            unset( $row_a["hersteller"] );
635
        }
636
 
637
        // PL: Bestandskennzeichnung
638
        if ( isset( $web_rechte['Warenwirtschaft']['lagerwirtschaft']['lagerwirtschaft'] ) )
639
        {
640
            $row_a['bestandsmenge'] = getBestandsmenge( $row_a["artikel"] );
641
        }
642
        $daten["Bestellung"]["artikel"][] = $row_a;
643
 
644
    }
645
 
646
    $sql_g = "SELECT
647
            ab.*,
648
            b.erstellt_am,
649
            a.short_line_2
650
        FROM
651
            artikel_to_Bestellung ab
652
        LEFT JOIN
653
				" . artikelDatabase( $daten["Bestellung"]["shops_ID"] ) . " AS a
654
        ON
655
            ab.artikel = a.ID
656
        LEFT JOIN
657
            Bestellung b
658
        ON
659
            b.ID = ab.Bestellung
660
        WHERE
661
            ab.Bestellung = " . $daten["Bestellung"]["ID"] . "
662
        AND
663
            a.Father = -5
664
        AND
665
            ab.status IN ('offen','in Bearbeitung')
666
        LIMIT 1
667
    ";
668
    $res_g = mysql_query( $sql_g );
669
    $row_g = mysql_fetch_assoc( $res_g );
670
    if ( $row_g )
671
    {
672
        $gs = true;
673
        $gutschein["name"] = $row_g["Bezeichnung"];
674
        $days = 1905;
675
        if ( $row_g["short_line_2"] )
676
        {
677
            $days = $row_g["short_line_2"];
678
        }
679
        $gutschein["gueltig"] = date( "d.m.Y", strtotime( $days . " days",
680
            strtotime( $row_g["erstellt_am"] ) ) );
681
        $gutschein["anfangswert"] = $row_g["Preis_pro_Stueck"];
682
        $GLOBALS["ui"]->assign( "gs", $gs );
683
        $gutschein["gs_artikel"] = $row_g["ID"];
684
        $gutschein["gs_a_status"] = $row_g["status"];
685
        $gutschein["gs_a_status_k"] = ( $row_g["status"] == "offen" ) ? "O" :
686
            "B";
687
        $GLOBALS["ui"]->assign( "gutschein", $gutschein );
688
    }
689
    //var_dump( $daten );
690
    $daten["artikel_stati"] = array( array( "name" => "offen", "short" =>
691
        "O", "class" => "status_red" ), array( "name" => "in Bearbeitung",
692
        "short" => "B", "class" => "status_yellow", ), array( "name" =>
693
        "reserviert", "short" => "R", "class" => "status_blue", ), array( "name" =>
694
        "erledigt", "short" => "E", "class" => "status_green", ), array( "name" =>
695
        "abgeschlossen", "short" => "A", "class" => "status_white", ), );
696
    $daten["rechnung_stati"] = array( array( "name" => "schreiben", "short" =>
697
        "S", "class" => "status_red" ), array( "name" => "geschrieben",
698
        "short" => "G", "class" => "status_yellow", ), array( "name" =>
699
        "bezahlt", "short" => "B", "class" => "status_green", ), );
700
    $daten["lieferschein_stati"] = array( array( "name" => "schreiben",
701
        "short" => "S", "class" => "status_yellow" ), array( "name" =>
702
        "geschrieben", "short" => "G", "class" => "status_green", ), array( "name" =>
703
        "offen", "short" => "O", "class" => "status_red", ), );
704
    $daten["mahnung_stati"] = array( array( "name" => "mahnung1", "short" =>
705
        "1", "class" => "status_green" ), array( "name" => "mahnung2",
706
        "short" => "2", "class" => "status_yellow", ), array( "name" =>
707
        "mahnung3", "short" => "3", "class" => "status_red", ), );
708
    $daten["garantie_stati"] = array( array( "name" => "eingereicht",
709
        "short" => "E", "class" => "status_red" ), array( "name" =>
710
        "abgeschlossen", "short" => "A", "class" => "status_green", ), );
711
 
712
    // Modul dokumente
713
    $Feld = "dokument";
714
 
715
    // Modconf => Bestellung
716
    $moduleTyp[tool_name] = array( "table_foreign" => "Bestellung",
717
        "row_foreign" => "ID", "data_foreign" => "ID" );
718
 
719
    $interneModulRechte = array( 0 => "_read", 1 => "_delete", 2 => "_add" );
720
 
721
    $daten["dokPath"] = "http://www.$site/images/dokumente/";
722
    $uploadPath = $webs['verzeichnis'] . "/images/dokumente/";
723
 
724
    if ( isset( $user_rechte[modul_name][tool_name][$Feld . $interneModulRechte[0]] ) )
725
    {
726
        $docCount = 1;
727
        $sql_d = "
728
            SELECT
729
                *
730
            FROM
731
                dokumente
732
            WHERE
733
                table_foreign = 'Bestellung'
734
            AND
735
                row_foreign = 'ID'
736
            AND
737
                data_foreign = '" . $row['ID'] . "'
738
            AND
739
                hidden=0
740
            ORDER BY
741
                letzte_aenderung_am
742
        ";
743
        $result_d = mysql_query_logged( $sql_d ) or die( mysql_errno() .
744
            ": " . mysql_error() . "<hr>" . nl2br( $sql_d ) . "<hr>" );
745
        $daten["add_document"] =
746
            "window.open('../dokumente/index.php?table_foreign=" . $moduleTyp[tool_name]['table_foreign'] .
747
            "&row_foreign=" . $moduleTyp[tool_name]['row_foreign'] .
748
            "&data_foreign=" . $row[$moduleTyp[tool_name]['data_foreign']] .
749
            "#', 'DokumentUpload', 'status, menubar, height=110, width=500');return false;";
750
        if ( mysql_num_rows( $result_d ) > 0 )
751
        {
752
            while ( $zeile_d = mysql_fetch_array( $result_d ) )
753
            {
754
                // Dateityp Icon definieren
755
                $fTmpName = $zeile_d['document'];
756
                $daten["dokumente"][$docCount - 1]["nr"] = $docCount;
757
                $daten["dokumente"][$docCount - 1]["id"] = $zeile_d['id'];
758
                $daten["dokumente"][$docCount - 1]["name"] = $fTmpName;
759
                $daten["dokumente"][$docCount - 1]["date"] = $zeile_d["letzte_aenderung_am"];
760
                $author = $zeile_d["letzte_aenderung_von"];
761
                $pos = strpos( $author, "@" );
762
                if ( $pos !== false )
763
                {
764
                    $author = substr( $zeile_d["letzte_aenderung_von"], 0, $pos );
765
                }
766
 
767
                $daten["dokumente"][$docCount - 1]["author"] = $author;
768
                $daten["dokumente"][$docCount - 1]["add_document"] =
769
                    "window.open('../dokumente/index.php?table_foreign=" . $moduleTyp[tool_name]['table_foreign'] .
770
                    "&row_foreign=" . $moduleTyp[tool_name]['row_foreign'] .
771
                    "&data_foreign=" . $row[$moduleTyp[tool_name]['data_foreign']] .
772
                    "#', 'DokumentUpload', 'status, menubar, height=110, width=500');return false;";
773
                $daten["dokumente"][$docCount - 1]["del_document"] =
774
                    "window.open('../dokumente/index.php?action=unlink&id=" .
775
                    $zeile_d['id'] . "&table_foreign=" . $moduleTyp[tool_name]['table_foreign'] .
776
                    "&row_foreign=" . $moduleTyp[tool_name]['row_foreign'] .
777
                    "&data_foreign=" . $row[$moduleTyp[tool_name]['data_foreign']] .
778
                    "#', 'DokumentUpload', 'status, menubar, height=110, width=500');return false;";
779
 
780
                $daten["dokumente"][$docCount - 1]["type"] = strtolower( substr
781
                    ( $fTmpName, strrpos( $fTmpName, "." ) + 1, strlen( $fTmpName ) ) );
782
                $start = substr( $zeile_d['document'], 0, 1 );
783
                $no_delete = array( "R", "L" );
784
                if ( in_array( $start, $no_delete ) )
785
                {
786
                    $daten["dokumente"][$docCount - 1]["deleteable"] = false;
787
                }
788
                else
789
                {
790
                    $daten["dokumente"][$docCount - 1]["deleteable"] = true;
791
                }
792
                $fTmpLinkIcon = "../dokumente/gfx/fileicons/" . $daten["dokumente"][$docCount -
793
                    1]["type"] . ".gif";
794
                $fTmpIcon =
795
                    "/web/apache/content-management/dokumente/gfx/fileicons/" .
796
                    $daten["dokumente"][$docCount - 1]["type"] . ".gif";
797
                $daten["dokumente"][$docCount - 1]["size"] = @filesize( $uploadPath .
798
                    $fTmpName );
799
                $daten["dokumente"][$docCount - 1]["icon"] = file_exists( $fTmpIcon ) ?
800
                    $fTmpLinkIcon : "../dokumente/gfx/fileicons/default.gif";
801
                $docCount++;
802
            }
803
        }
804
    }
805
    if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] ) )
806
    {
807
        $i = 0;
808
        $mailData[$zeile["ID"]][$i]['mailto'] = $zeile["E_Mail"];
809
        $FelddatenII = explode( ";", $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] );
810
        if ( $FelddatenII[0] == "websettingid" )
811
        {
812
            $mailData[$zeile["ID"]][$i]['mailfrom'] = $web_settings[$zeile["shops_ID"]][$FelddatenII[1]];
813
        }
814
        if ( isset( $web_settings[$zeile["shops_ID"]][198] ) )
815
        {
816
            $mailData[$zeile["ID"]][$i]['subject'] = $web_settings[$zeile["shops_ID"]][198];
817
        }
818
        if ( isset( $web_settings[$zeile["shops_ID"]][199] ) )
819
        {
820
            $mailData[$zeile["ID"]][$i]['body'] = $web_settings[$zeile["shops_ID"]][199];
821
        }
822
        $mailData[$zeile["ID"]][$i]['inTextField'] = "Sonstige E-Mail von " .
823
            $_SERVER["PHP_AUTH_USER"] . " am " . date( "d.m.Y" ) . " um " .
824
            date( "H:i" ) . " Uhr veschickt" . '\n';
825
    }
826
    for ( $i = 1; $i <= 15; $i++ )
827
    {
828
        if ( isset( $web_rechte[modul_name][tool_name]["button" . $i] ) )
829
        {
830
            $Felddaten = explode( ";", $web_rechte[modul_name][tool_name]["button" .
831
                $i] );
832
            if ( isset( $user_rechte[modul_name][tool_name]["button" . $i] ) and
833
                ( $web_settings[$zeile["shops_ID"]][$Felddaten[1]] ) )
834
            {
835
                // Mail Client dazuschalten (Markus 02.07.207)
836
                $buttonType = isset( $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] ) ?
837
                    "button" : "submit";
838
                if ( isset( $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] ) )
839
                {
840
                    $mailData[$zeile["ID"]][$i]['subject'] = $web_settings[$zeile["shops_ID"]][$Felddaten[1]];
841
                    $mailData[$zeile["ID"]][$i]['body'] = $web_settings[$zeile["shops_ID"]][$Felddaten[2]];
842
                    $mailData[$zeile["ID"]][$i]['inTextField'] =
843
                        rawurldecode( $web_settings[$zeile["shops_ID"]][$Felddaten[3]] );
844
                    $mailData[$zeile["ID"]][$i]['mailto'] = $zeile["E_Mail"];
845
                    $FelddatenII = explode( ";", $web_rechte["Warenwirtschaft"]["bestellung"]["mail_client"] );
846
                    if ( $FelddatenII[0] == "websettingid" )
847
                    {
848
                        $mailData[$zeile["ID"]][$i]['mailfrom'] = $web_settings[$zeile["shops_ID"]][$FelddatenII[1]];
849
                    }
850
 
851
                    $_SESSION['mailData'] = $mailData;
852
 
853
                    if ( $_SERVER["REMOTE_ADDR"] == "89.245.130.99" )
854
                    {
855
                        //print_r($web_settings[1]);
856
                    }
857
 
858
                    /*$onClick = "window.open('MailClient/index.php?mailto=" . $zeile[E_Mail] .
859
                    "&subject=" . $web_settings[$zeile[shops_ID]][$Felddaten[1]] . "&body=" . $web_settings[$zeile[shops_ID]][$Felddaten[2]] .
860
                    "&inTextField=" . $web_settings[$zeile[shops_ID]][$Felddaten[3]] .
861
                    "', 'MailClient', 'status, menubar, height=600, width=900');";*/
862
                    $onSubmit = "window.open('MailClient/index.php?id=$i&Bestellung=" .
863
                        $zeile["ID"] . "&shop=" . $zeile["shops_ID"] .
864
                        "&button=" . $Felddaten[0] .
865
                        "', 'MailClient', 'status, menubar, height=600, width=900, scrollbars=yes');";
866
                    $onClick = $onSubmit;
867
                }
868
                else
869
                {
870
                    $onClick = "MM_goToURL('parent','mailto:" . $zeile["E_Mail"] .
871
                        "?subject=" . $web_settings[$zeile["shops_ID"]][$Felddaten[1]] .
872
                        "&body=" . $web_settings[$zeile["shops_ID"]][$Felddaten[2]] .
873
                        "'); inTextfeld('" . rawurldecode( $web_settings[$zeile["shops_ID"]][$Felddaten[3]] ) .
874
                        "');";
875
                }
876
                $daten["buttons"][] = array( "type" => $buttonType, "name" =>
877
                    "update[list]", "class" => "status_red", "onClick" => $onClick,
878
                    "value" => $Felddaten[0] );
879
            }
880
        }
881
    }
882
 
883
    $GLOBALS["ui"]->assign( "user_rechte", $user_rechte );
884
    $GLOBALS["ui"]->assign( "web_rechte", $web_rechte );
885
    $shops = getShops();
886
    foreach ( $shops as $s_id => $shop )
887
    {
888
        $c_shops[$shop["ID"]] = $shop["Name"];
889
        $d_shops[$shop["ID"]] = $shop;
890
    }
891
 
892
    $Feld = "shortline1";
893
    if ( isset( $user_rechte[modul_name][tool_name][$Feld] ) )
894
    {
895
        $fname_f = $web_rechte[modul_name][tool_name][$Feld];
896
        $pos = strpos( $fname_f, ";" );
897
        $daten["sl1"]["name"] = substr( $fname_f, 0, $pos );
898
        $daten["sl1"]["size"] = substr( $fname_f, $pos + 1 );
899
    }
900
    $Feld = "shortline2";
901
    if ( isset( $user_rechte[modul_name][tool_name][$Feld] ) )
902
    {
903
        $fname_f = $web_rechte[modul_name][tool_name][$Feld];
904
        $pos = strpos( $fname_f, ";" );
905
        $daten["sl2"]["name"] = substr( $fname_f, 0, $pos );
906
        $daten["sl2"]["size"] = substr( $fname_f, $pos + 1 );
907
    }
908
    if ( isset( $user_rechte["Warenwirtschaft"]["logistiker"]["logistiker"] ) )
909
    {
910
        $logistiker[] = "Bitte wählen";
911
        $sql_l = "SELECT
912
                id,
913
                name
914
            FROM
915
                logistiker
916
        ";
917
        $res_l = mysql_query( $sql_l );
918
        while ( $row_l = mysql_fetch_assoc( $res_l ) )
919
        {
920
            $logistiker[$row_l["id"]] = $row_l["name"];
921
        }
922
        $sql_bl="SELECT
923
                logistiker
924
            FROM
925
                bestellung_logistiker bl
926
            WHERE
927
                bl.bestellung=".$row["ID"]."
928
        ";
929
        $res_bl = mysql_query( $sql_bl );
930
 
931
        $row_bl = mysql_fetch_assoc( $res_bl );
932
        $GLOBALS["ui"]->assign( "logistiker", $logistiker );
933
 
934
        $GLOBALS["ui"]->assign( "logistiker_sel", $row_bl["logistiker"] );
935
    }
936
    if ( isset( $user_rechte["Warenwirtschaft"]["bestellung"]["tracking"] ) )
937
    {
938
        if ( $web_rechte["Warenwirtschaft"]["bestellung"]["tracking"] )
939
        {
940
            $daten_p = explode( ";", $web_rechte["Warenwirtschaft"]["bestellung"]["tracking"] );
941
            $daten["paketdienst"]["name"] = $daten_p[0];
942
            $daten["paketdienst"]["url"] = $daten_p[1];
943
            $sql = "
944
                SELECT
945
                    *
946
                FROM
947
                    bestellung_paketnummern
948
                WHERE
949
                    Bestellung=" . $row["ID"] . "
950
                ORDER BY
951
                    datum
952
            ";
953
            $res = mysql_query( $sql );
954
            while ( $row_p = mysql_fetch_assoc( $res ) )
955
            {
956
                $daten["paketdienst"]["nummern"][] = array( "nummer" => $row_p["paketnummer"],
957
                    "datum" => $row_p["datum"] );
958
            }
959
        }
960
    } elseif ( isset( $user_rechte["Warenwirtschaft"]["logistiker"]["logistiker"] ) )
961
    {
962
        $sql = "
963
                SELECT
964
                    bp.*,
965
                    l.name AS logistiker_name,
966
                    l.trackinglink
967
                FROM
968
                    bestellung_paketnummern bp,
969
                    logistiker l
970
                WHERE
971
                    Bestellung=" . $row["ID"] . "
972
                AND
973
                    l.id=bp.logistiker
974
                ORDER BY
975
                    datum
976
            ";
977
        $res = mysql_query( $sql );
978
        while ( $row_p = mysql_fetch_assoc( $res ) )
979
        {
980
            $daten["paketdienst"]["nummern"][] = array( "nummer" => $row_p["paketnummer"],
981
                "datum" => $row_p["datum"], "name" => $row_p["logistiker_name"],
982
                "url" => $row_p["trackinglink"], );
983
        }
984
    }
985
    $rowspan = count( $daten["Bestellung"]["artikel"] ) + 4;
986
    $tpl_file = ( $filter_maske === false ) ?
987
        "bestellungen_formular_pdf.tpl" : "bestellungen_formular.tpl";
988
 
989
    $GLOBALS["ui"]->assign( "c_shops", $c_shops );
990
    $GLOBALS["ui"]->assign( "d_shops", $d_shops );
991
    $GLOBALS["ui"]->assign( "preise_anzeigen", $preise_anzeigen );
992
    $GLOBALS["ui"]->assign( "daten", $daten );
993
    $GLOBALS["ui"]->assign( "rowspan", $rowspan );
994
    $GLOBALS["ui"]->assign( "d_colspan", $d_colspan );
995
    if ( isset( $web_rechte['Warenwirtschaft']['lagerwirtschaft']['bestandskennzeichnung'] ) )
996
    {
997
        $GLOBALS["ui"]->assign( "bestandskennzeichnungsfarbe",
998
            getBestandskennzeichnung( $web_rechte['Warenwirtschaft']['lagerwirtschaft']['bestandskennzeichnung'] ) );
999
    }
1000
 
1001
    // type = 0 normaler E-Mail Text mit \n
1002
    // type = 1 Ausgabetext für RS (Bestellung) mit <br> statt \n
1003
    function buildCustomTextEmail( $get, $type = 0 )
1004
    {
1005
        if ( $type == 1 )
1006
        {
1007
            $cont = "<br>Details:";
1008
        }
1009
        else
1010
        {
1011
            $cont = "\nDetails:";
1012
        }
1013
        for ( $i = 0; $i < $get['ct_zeilen']; $i++ )
1014
        {
1015
            $opt = array();
1016
            $align = "zentriert";
1017
            $bold = "";
1018
            $italic = "";
1019
            $underline = "";
1020
            $file = "";
1021
            if ( $get['ct_left_' . $i . ''] == "left" )
1022
                $align = "linksbündig";
1023
            if ( $get['ct_center_' . $i . ''] == "center" )
1024
                $align = "zentriert";
1025
            if ( $get['ct_right_' . $i . ''] == "right" )
1026
                $align = "rechtsbündig";
1027
            if ( $get['ct_bold_' . $i . ''] == "on" )
1028
                $bold = "fett";
1029
            if ( $get['ct_italic_' . $i . ''] == "on" )
1030
                $italic = "kursiv";
1031
            if ( $get['ct_underline_' . $i . ''] == "on" )
1032
                $underline = "unterstrichen";
1033
            if ( $get['ct_font_' . $i] . '' )
1034
                $font = $get['ct_font_' . $i . ''];
1035
            if ( $get['ct_file'] )
1036
                $file = "Bilddatei: " . $get['ct_file'];
1037
            if ( $font )
1038
                $opt[] = $font;
1039
            if ( $align )
1040
                $opt[] = $align;
1041
            if ( $bold )
1042
                $opt[] = $bold;
1043
            if ( $italic )
1044
                $opt[] = $italic;
1045
            if ( $underline )
1046
                $opt[] = $underline;
1047
            if ( $file )
1048
                $opt[] = $file;
1049
 
1050
            if ( $type == 1 )
1051
            {
1052
                $cont .= "<br> " . ( $i + 1 ) . ". Zeile: " . $get['ct_text_' .
1053
                    $i . ''] . " (" . $get['ct_fontsize_' . $i . ''] . ", " .
1054
                    implode( ", ", $opt ) . ")";
1055
            }
1056
            else
1057
            {
1058
                $cont .= "\n" . ( $i + 1 ) . ". Zeile: " . $get['ct_text_' .
1059
                    $i . ''] . " (" . $get['ct_fontsize_' . $i . ''] . ", " .
1060
                    implode( ", ", $opt ) . ")";
1061
            }
1062
        }
1063
        return $cont;
1064
    }
1065
?>