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    Lars Tiefland <tiefland@weban.de>
6
     * @copyright 2010 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 3931 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Lars Tiefland <tiefland@weban.de>
17
     * @copyright 2010 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: gutscheinvorlage.php 3931 2011-09-16 08:17:57Z tiefland $
21
 
22
    require_once "../toolbox/common.php";
23
    require_once
24
        "../Warenwirtschaft/includes/bestellungen/system/artikelDatabase.php";
25
 
26
    require_once "../Warenwirtschaft/includes/best_manu/system/getShops.php";
27
    $shop_id = filter_input( INPUT_POST, "shop_id", FILTER_VALIDATE_INT );
28
    $shops = getShops();
29
    $shop_ids = array_keys( $shops );
30
    $default_shop = $shop_ids[0];
31
    $GLOBALS["ui"]->assign( "default_shop", $default_shop );
32
    if ( is_null( $shop_id ) )
33
    {
34
        $shop_id = 0;
35
    }
36
 
37
    if ( $_GET["action"] )
38
    {
39
        $action = $_GET["action"];
40
    } elseif ( $_POST["action"] )
41
    {
42
        $action = $_POST["action"];
43
    }
44
    $preis = $_POST["preis1"];
45
    if ( stristr( $preis, "%" ) )
46
    {
47
        $preis *= -1;
48
    }
49
    switch ( $_POST["action"] )
50
    {
51
        case "edit":
52
            if ( $_POST["ID"] )
53
            {
54
                $sql = "
55
                    UPDATE
56
                        artikel
57
                    SET
58
                        status='" . mysql_real_escape_string( $_POST["shop_id"] ) .
59
                    "',
60
                        preis1='" . mysql_real_escape_string( $preis ) . "',
61
                ";
62
                if ( isset( $user_rechte["marketing"]["gutscheinvorlage"]["mindestbestellwert"] ) )
63
                {
64
                    $sql .= "preis2='" . mysql_real_escape_string( $_POST["preis2"] ) .
65
                        "',";
66
 
67
                }
68
                $sql .= "
69
                        kurzbezeichnung='" . mysql_real_escape_string( $_POST["kurzbezeichnung"] ) .
70
                    "',
71
                        short_line_1='" . mysql_real_escape_string( $_POST["short_line_1"] ) .
72
                    "',
73
                        short_line_2 = " . intval( $_POST["short_line_2"] ) .
74
                    "
75
                    WHERE
76
                        id=" . $_POST["ID"] . "
77
            ";
78
 
79
            }
80
            else
81
            {
82
                $sql = "
83
                    INSERT INTO
84
                        artikel
85
                    (
86
                        status,
87
                ";
88
                if ( isset( $user_rechte["marketing"]["gutscheinvorlage"]["mindestbestellwert"] ) )
89
                {
90
                    $sql .= "
91
                        preis2,
92
                    ";
93
                }
94
                $sql .= "
95
                        preis1,
96
                        kurzbezeichnung,
97
                        father,
98
                        short_line_2
99
                    )
100
                    VALUES
101
                    (
102
                        '" . mysql_real_escape_string( $_POST["shop_id"] ) .
103
                    "',";
104
                if ( isset( $user_rechte["marketing"]["gutscheinvorlage"]["mindestbestellwert"] ) )
105
                {
106
                    $sql .= "
107
                        '" . mysql_real_escape_string( $_POST["preis2"] ) .
108
                        "',
109
                    ";
110
                }
111
                $sql .= "
112
                        '" . mysql_real_escape_string( $_POST["preis1"] ) .
113
                    "',
114
                        '" . mysql_real_escape_string( $_POST["kurzbezeichnung"] ) .
115
                    "',
116
                    -5,
117
                    " . intval( $_POST["short_line_2"] ) .
118
                    "                    )
119
                ";
120
            }
121
            $res = mysql_query( $sql );
122
            var_dump(mysql_error());
123
            $action = "select_edit";
124
            break;
125
        case "delete":
126
            $action = "select_edit";
127
            break;
128
    }
129
    switch ( $action )
130
    {
131
        case "edit":
132
            if ( $_GET["ID"] )
133
            {
134
                $vorlage = getVorlage( $_GET["ID"], $_GET["shop_id"] );
135
            }
136
            $GLOBALS["ui"]->assign( "vorlage", $vorlage );
137
            $GLOBALS["ui"]->assign( "file", "vorlage.tpl" );
138
            break;
139
        case "delete":
140
            delVorlage($_GET["ID"]);
141
        case "select_edit":
142
        default:
143
            $vorlagen = getVorlagen( $shop_id );
144
            $GLOBALS["ui"]->assign( "vorlagen", $vorlagen );
145
            $GLOBALS["ui"]->assign( "file", "vorlagen.tpl" );
146
            break;
147
    }
148
 
149
    function getVorlagen( $shop_id = 1 )
150
    {
151
        $table = "artikel";
152
        $sql = "SELECT
153
                *
154
            FROM
155
                $table
156
            WHERE
157
                Father = -5
158
            AND
159
                status=$shop_id
160
        ";
161
        $res = mysql_query( $sql );
162
        while ( $row = mysql_fetch_assoc( $res ) )
163
        {
164
            $vorlagen[] = $row;
165
        }
166
        return $vorlagen;
167
    }
168
    function getVorlage( $v_id, $shop_id = 1 )
169
    {
170
        $table = "artikel";
171
        $sql = "SELECT
172
                *
173
            FROM
174
                $table
175
            WHERE
176
                Father = -5
177
            AND
178
                ID=$v_id
179
        ";
180
 
181
        $res = mysql_query( $sql );
182
        $row = mysql_fetch_assoc( $res );
183
        return $row;
184
    }
185
 
186
    function delVorlage($v_id)
187
    {
188
        $table = "artikel";
189
        $sql = "DELETE FROM
190
                $table
191
            WHERE
192
                ID=$v_id
193
        ";
194
 
195
        $res = mysql_query( $sql );
196
    }
197
    //$GLOBALS["ui"]->security = true;
198
    $GLOBALS["ui"]->assign( "shops", $shops );
199
    $GLOBALS["ui"]->assign( "shop_id", $shop_id );
200
    $GLOBALS["ui"]->display( "gs_vorlagen.tpl" );
201
    //var_dump( $GLOBALS["ui"] );
202
 
203
?>