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: 3931 $
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: optionen_kopieren.php 3931 2011-09-16 08:17:57Z tiefland $
21
 
22
    require_once "../toolbox/common.php";
23
 
24
    if ( isset( $_POST["dir"] ) )
25
    {
26
        $dir = filter_input( INPUT_POST, "dir", FILTER_VALIDATE_INT );
27
        foreach ( $_POST["Option"] as $opt_id => $active )
28
        {
29
            if ( $active )
30
            {
31
                $sum[$opt_id] = array_sum( $_POST["Value"][$opt_id] );
32
            }
33
            else
34
            {
35
                $sum[$opt_id] = 0;
36
            }
37
        }
38
        $sql = "SELECT
39
                a.ID
40
            FROM
41
                artikel a
42
            WHERE
43
                Father=$dir
44
            AND
45
                Language='" . $_SESSION["language"] . "'
46
        ";
47
        $res = mysql_query( $sql );
48
        while ( $row = mysql_fetch_assoc( $res ) )
49
        {
50
            $a_id = $row["ID"];
51
            $sql_d = "DELETE FROM
52
                    Feature_to_Ware
53
                WHERE
54
                    Ware = $a_id
55
            ";
56
            $res_d = mysql_query( $sql_d );
57
            foreach ( $sum as $option_id => $value )
58
            {
59
                if ( $value )
60
                {
61
                    $sql_i = "
62
                        INSERT INTO
63
                            Feature_to_Ware
64
                        (
65
                            Ware,
66
                            Feature,
67
                            Feature_options
68
                        )
69
                        VALUES
70
                        (
71
                            $a_id,
72
                            $option_id,
73
                            $value
74
                        )
75
                    ";
76
                    $res_i = mysql_query( $sql_i );
77
                }
78
            }
79
        }
80
        //exit;
81
        header( "Location: directory.php?action=edit&ID=" . $dir );
82
    } elseif ( isset( $_GET["dir"] ) )
83
    {
84
        $dir = filter_input( INPUT_GET, "dir", FILTER_VALIDATE_INT );
85
        $sql = "SELECT
86
                f.ID,
87
                f.Name
88
            FROM
89
                Features f
90
            WHERE
91
                f.Language='" . $_SESSION["language"] . "'
92
        ";
93
        $res = mysql_query( $sql );
94
        while ( $feature = mysql_fetch_assoc( $res ) )
95
        {
96
            $sql_fo = "SELECT
97
                    Value,
98
                    bit
99
                FROM
100
                    Feature_options
101
                WHERE
102
                    Feature=" . $feature["ID"] . "
103
                ORDER BY
104
                    ID,
105
                    bit
106
            ";
107
            $res_fo = mysql_query( $sql_fo );
108
            while ( $row_fo = mysql_fetch_assoc( $res_fo ) )
109
            {
110
                $row_fo["bit_input"]= 1 << $row_fo["bit"];
111
                $feature["options"][] = $row_fo;
112
            }
113
            $features[] = $feature;
114
        }
115
        $GLOBALS["ui"]->assign( "features", $features );
116
        if ( !is_null( $dir ) )
117
        {
118
            $sort = $_SESSION["tree.php"]["output"]["artikel_sort"];
119
            $sql = "SELECT
120
                    a.ID,
121
                    a.kurzbezeichnung
122
                FROM
123
                    artikel a
124
            ";
125
            if ( stristr( $_SESSION[$self]["output"]["artikel_sort"],
126
                "hersteller" ) )
127
            {
128
                $sql .= ", Herstellerkatalog hk";
129
            }
130
            $sql .= "
131
                WHERE
132
                    Father=$dir
133
                AND
134
                    language='" . $_SESSION["language"] . "'
135
            ";
136
            if ( stristr( $_SESSION["tree.php"]["output"]["artikel_sort"],
137
                "hersteller" ) )
138
            {
139
                $sql .= "
140
                    AND
141
                    (
142
                        (hk.ID=a.hersteller)
143
                        OR
144
                        (a.hersteller=0)
145
                    )
146
                ";
147
                $sort = "hk.Name," . $_SESSION["tree.php"]["output"]["artikel_sort"];
148
            }
149
            $sql .= "
150
                ORDER BY
151
                    $sort
152
                LIMIT 1
153
            ";
154
            $res = mysql_query( $sql );
155
            $row = mysql_fetch_assoc( $res );
156
            if ( is_array( $row ) )
157
            {
158
                foreach ( $features as $f_id => $feature )
159
                {
160
                    $i = $feature["ID"];
161
                    $sql_fw = "SELECT
162
                            Feature,
163
                            Feature_options AS bits
164
                        FROM
165
                            Feature_to_Ware
166
                        WHERE
167
                            Ware=" . $row["ID"] . "
168
                        AND
169
                            Feature = $i
170
                        ORDER BY
171
                            Feature
172
                    ";
173
                    $res_fw = mysql_query( $sql_fw );
174
                    $row_fw = mysql_fetch_assoc( $res_fw );
175
                    foreach ( $feature["options"] as $data )
176
                    {
177
                        if ( $row_fw["bits"] & $data["bit_input"] )
178
                        {
179
                            $row_fw["values"][] = $data["bit_input"];
180
                        }
181
                        else
182
                        {
183
                            $row_fw["values"][] = null;
184
                        }
185
                    }
186
                    $row["features"][$row_fw["Feature"]] = $row_fw;
187
                }
188
                $GLOBALS["ui"]->assign( "artikel", $row );
189
                $GLOBALS["ui"]->assign( "dir", $dir );
190
            }
191
            else
192
            {
193
                $GLOBALS["ui"]->assign( "error", true );
194
                $GLOBALS["ui"]->assign( "meld", "Keine Artikel in diesem Ordner" );
195
            }
196
        }
197
        $GLOBALS["ui"]->assign( "tpl_f", "optionen_kopieren.tpl" );
198
        $GLOBALS["ui"]->display( "page.tpl" );
199
    }
200
?>