Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    /**
4
     * @package   Content-management
5
     * @author    Webagentur Niewerth <tiefland@weban.de>
6
     * @copyright 2011 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 768 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Webagentur Niewerth <tiefland@weban.de>
17
     * @copyright 2011 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: preisstaffel.php 768 2011-10-28 06:34:37Z tiefland $
21
 
22
    require_once "../toolbox/common.php";
23
    if ( isset( $_GET["id"] ) )
24
    {
25
        $id = Weban_Utils::clean_global_input( "id", "get", "int" );
26
        $sql = "SELECT
27
                preis
28
            FROM
29
                preise_to_login pl
30
            WHERE
31
                id=" . $id . "
32
        ";
33
        $res = mysql_query( $sql );
34
        while ( $row = mysql_fetch_assoc( $res ) )
35
        {
36
            $row["preis"] = unserialize( $row["preis"] );
37
            $daten = $row["preis"];
38
        }
39
        $GLOBALS["ui"]->assign( "preis", $daten );
40
        $GLOBALS["ui"]->assign( "i", 1 );
41
        $GLOBALS["ui"]->assign( "id", $id );
42
        $GLOBALS["ui"]->display( "preisstaffel.tpl" );
43
    } elseif ( isset( $_POST["mode"] ) )
44
    {
45
        foreach ( $_POST["staffel"][1]["preis"] as $p_ind => $preis )
46
        {
47
            if ( stristr( $preis, "%" ) )
48
            {
49
                $_POST["staffel"][1]["preis"][$p_ind] = $preis * -1;
50
            }
51
        }
52
        $staffel = serialize( $_POST["staffel"][1] );
53
        $id = Weban_Utils::clean_global_input( "id", "post", "int" );
54
        $mode = Weban_Utils::clean_global_input( "mode" );
55
        $login_id = Weban_Utils::clean_global_input( "login_id", "post", "int" );
56
        if ( $id )
57
        {
58
            if ( $mode == "save" )
59
            {
60
                $sql = "
61
                    UPDATE
62
                        preise_to_login
63
                    SET
64
                        preis='" . $staffel . "',
65
                        letzte_aenderung_von='" . $_SERVER["PHP_AUTH_USER"] . "'
66
                    WHERE
67
                        id=" . $id . "
68
                ";
69
            } elseif ( $mode == "delete" )
70
            {
71
                $sql = "
72
                    DELETE FROM
73
                        preise_to_login
74
                    WHERE
75
                        id=" . $id . "
76
                ";
77
            }
78
        }
79
        else
80
        {
81
            $sql = "
82
                INSERT INTO
83
                    preise_to_login
84
                SET
85
                    preis='" . $staffel . "',
86
                    shop_id=" . $shop_id . ",
87
                    artikel_id=" . $artikel_id . ",
88
                    login_id=" . $login_id . ",
89
                    erstellt_von='" . $_SERVER["PHP_AUTH_USER"] . "',
90
                    erstellt_am=NOW(),
91
                    letzte_aenderung_von='" . $_SERVER["PHP_AUTH_USER"] . "'
92
            ";
93
        }
94
        echo $sql;
95
        $res = mysql_query( $sql );
96
        if ( !$res )
97
        {
98
            echo mysql_error() . "\n$sql";
99
        }
100
    }
101
?>