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
    if ( !function_exists( 'numberFormat' ) )
4
    {
5
        function numberFormat( $nbr, $n = 2, $s = '.', $ss = '.' )
6
        {
7
            return number_format( $nbr, $n, $s, $ss );
8
        }
9
    }
10
 
11
    function getArtikelListe( $BestellID = null, $shops_ID = 1 )
12
    {
13
        $query = "
14
			select
15
				artikel_to_Bestellung.ID as ab_id,
16
				artikel_to_Bestellung.status as artikelStatus,
17
				artikel_to_Bestellung.Preis_pro_Stueck,
18
				artikel_to_Bestellung.Menge,
19
				artikel_to_Bestellung.Bezeichnung,
20
				artikel_to_Bestellung.Bestellung,
21
				artikel_to_Bestellung.rechnungStatus,
22
				artikel_to_Bestellung.lieferscheinStatus,
23
				" . artikelDatabase( $shops_ID ) . ".*,
24
				ifnull(" . artikelDatabase( $shops_ID ) . ".Father, 1) as Father,
25
				ifnull(artikel_to_Bestellung.Bezeichnung, " . artikelDatabase( $shops_ID ) .
26
            ".kurzbezeichnung) as kurzbezeichnung
27
			from
28
				shops
29
			join
30
				artikel_to_Bestellung
31
			join
32
				Bestellung
33
			left join
34
				" . artikelDatabase( $shops_ID ) . "
35
			on
36
				artikel_to_Bestellung.artikel=" . artikelDatabase( $shops_ID ) . ".ID
37
			and
38
				" . artikelDatabase( $shops_ID ) . ".language=Bestellung.Language
39
			where
40
				Bestellung.ID = " . $BestellID . "
41
			and
42
				artikel_to_Bestellung.Bestellung = Bestellung.ID
43
			and
44
				shops.ID = Bestellung.shops_ID
45
			order by
46
				Father desc,
47
				" . artikelDatabase( $shops_ID ) . ".Kennung
48
			";
49
 
50
        $result = mysql_query( $query ) or mail( "admin@weban.de",
51
            "Fehler in createOrderText.php", mysql_errno() . ": " .
52
            mysql_error() . "<hr>$query<hr>", "from: weban.de" );
53
        return $result;
54
 
55
    }
56
 
57
    function Bestellwert_brutto( $BestellID, $shops_ID )
58
    {
59
        if ( $BestellID == null )
60
        {
61
            return;
62
        }
63
 
64
        $result = getArtikelliste( $BestellID, $shops_ID );
65
        $preis = 0;
66
        while ( $zeile = mysql_fetch_array( $result ) )
67
        {
68
            $preis += $zeile['Menge'] * $zeile['Preis_pro_Stueck'];
69
        }
70
        return numberFormat( $preis, 2, ',', '.' );
71
    }
72
 
73
 
74
    function createOrderText( $BestellID = null, $shops_ID = 1 )
75
    {
76
        if ( $BestellID == null )
77
        {
78
            return;
79
        }
80
 
81
        $text = "\nMenge   Art-Nr. Artikelname                      Einzelpreis    Gesamtpreis\n___________________________________________________________________________\n";
82
 
83
        $result = getArtikelliste( $BestellID, $shops_ID );
84
        $preis = 0;
85
        while ( $zeile = mysql_fetch_array( $result ) )
86
        {
87
            //pre($zeile);
88
            $preis += $zeile['Menge'] * $zeile['Preis_pro_Stueck'];
89
 
90
            if ( !( ( $zeile["Father"] > -3 ) or ( $zeile["Father"] == "" ) ) and
91
                !( $zeile["artikelStatus"] != 'versand' ) )
92
            {
93
                $text = $text . "\n1     x Versand: " . str_pad( $zeile['kurzbezeichnung'],
94
                    42 ) . str_pad( number_format( $zeile['Preis_pro_Stueck'],
95
                    2, ',', '.' ), 11, " ", STR_PAD_LEFT ) . " Euro\n";
96
            }
97
            else
98
            {
99
                $optionen = "";
100
                /* START Artikeloptionen zusammenstellen */
101
                if ( isset( $zeile["options"] ) )
102
                {
103
                    if ( is_array( $zeile['option'] ) )
104
                    {
105
                        $query_Feature_options =
106
                            "select * from Feature_options where ID = " .
107
                            implode( " or ID = ", $zeile['option'] );
108
                        $result_Feature_options = mysql_query( $query_Feature_options ) or
109
                            mail( "admin@weban.de",
110
                            "Fehler2 in createOrderText.php", mysql_errno() .
111
                            ": " . mysql_error() . "<hr>$query<hr>",
112
                            "from: weban.de" );
113
 
114
 
115
                        while ( $zeile_Feature_options = mysql_fetch_array( $result_Feature_options ) )
116
                        {
117
                            $Feature_options[] = $zeile_Feature_options['Value'];
118
                        }
119
                        $optionen = " (" . implode( ", ", $Feature_options ) .
120
                            ")";
121
                        unset( $Feature_options );
122
                    }
123
                    else
124
                    {
125
                        $optionen = "";
126
                    }
127
                }
128
                $artikeltext = $zeile['kennung'] . " " . $zeile['kurzbezeichnung'] .
129
                    " " . $optionen;
130
                /* STOP Artikeloptionen zusammenstellen */
131
                $text = $text . str_pad( $zeile['Menge'], 5 ) . " x " .
132
                    str_pad( $artikeltext, 40 ) . " " . str_pad( numberFormat
133
                    ( $zeile['Preis_pro_Stueck'], 2, ',', '.' ), 6, " ",
134
                    STR_PAD_LEFT ) . " Euro" . str_pad( numberFormat( $zeile['Menge'] *
135
                    $zeile['Preis_pro_Stueck'], 2, ',', '.' ), 10, " ",
136
                    STR_PAD_LEFT ) . " Euro\n";
137
            }
138
        }
139
        $mwst = 19;
140
        $mwst = $preis / ( 100 + $mwst ) * $mwst;
141
        $text = $text .
142
            "___________________________________________________________________________\nGesamtsumme (Brutto): " .
143
            str_pad( numberFormat( $preis, 2, ',', '.' ), 48, " ",
144
            STR_PAD_LEFT ) . " Euro\nEnthaltene MwSt. (19 %):" . str_pad( numberFormat
145
            ( $mwst, 2, ',', '.' ), 46, " ", STR_PAD_LEFT ) . " Euro";
146
        /*
147
        echo "
148
        <!--
149
        $text
150
        -->";
151
        */
152
        return $text;
153
    }
154
 
155
    function createOrderText_html( $BestellID = null, $shops_ID = 1 )
156
    {
157
        $text = "
158
    <table><tr align='left'><th>Menge</th><th>Art.Nr.</th><th>Artikelname</th><th>Einzelpreis</th><th>Gesamtpreis</th></tr>";
159
        $result = getArtikelListe( $BestellID, $shops_ID );
160
 
161
        $preis = 0;
162
        while ( $zeile = mysql_fetch_array( $result ) )
163
        {
164
            //pre($zeile);
165
            $preis += $zeile['Menge'] * $zeile['Preis_pro_Stueck'];
166
            if ( !( ( $zeile["Father"] > -3 ) or ( $zeile["Father"] == "" ) ) and
167
                !( $zeile["artikelStatus"] != 'versand' ) )
168
            {
169
                $items[] = "<td>" . $zeile["Menge"] .
170
                    "</td><td>Versand</td><td>" . $zeile["kurzbezeichnung"] .
171
                    "</td><td align='right'>" . number_format( $zeile["Preis_pro_Stueck"],
172
                    2, ',', '.' ) . " &euro;</td><td align='right'>" .
173
                    number_format( $zeile["Menge"] * $zeile["Preis_pro_Stueck"],
174
                    2, ',', '.' ) . " &euro;</td>";
175
            }
176
            else
177
            {
178
                $optionen = "";
179
                /* START Artikeloptionen zusammenstellen */
180
                if ( isset( $zeile["options"] ) )
181
                {
182
                    if ( is_array( $zeile['option'] ) )
183
                    {
184
                        $query_Feature_options =
185
                            "select * from Feature_options where ID = " .
186
                            implode( " or ID = ", $zeile['option'] );
187
                        $result_Feature_options = mysql_query( $query_Feature_options ) or
188
                            mail( "admin@weban.de",
189
                            "Fehler2 in createOrderText.php", mysql_errno() .
190
                            ": " . mysql_error() . "<hr>$query<hr>",
191
                            "from: weban.de" );
192
 
193
 
194
                        while ( $zeile_Feature_options = mysql_fetch_array( $result_Feature_options ) )
195
                        {
196
                            $Feature_options[] = $zeile_Feature_options['Value'];
197
                        }
198
                        $optionen = " (" . implode( ", ", $Feature_options ) .
199
                            ")";
200
                        unset( $Feature_options );
201
                    }
202
                    else
203
                    {
204
                        $optionen = "";
205
                    }
206
                }
207
 
208
                $artikeltext = $zeile['kennung'] . " " . $zeile['kurzbezeichnung'] .
209
                    " " . $optionen;
210
                /* STOP Artikeloptionen zusammenstellen */
211
                $items[] = "<td>" . $zeile["Menge"] . "</td><td>" . $zeile["kennung"] .
212
                    "</td><td>" . $zeile["kurzbezeichnung"] .
213
                    "</td><td align='right'>" . number_format( $zeile["Preis_pro_Stueck"],
214
                    2, ',', '.' ) . " &euro;</td><td align='right'>" .
215
                    number_format( $zeile["Menge"] * $zeile["Preis_pro_Stueck"],
216
                    2, ',', '.' ) . " &euro;</td>";
217
            }
218
        }
219
        $mwst = 19;
220
        $mwst = $preis / ( 100 + $mwst ) * $mwst;
221
        $items[] =
222
            "<td colspan='4'>Gesamtsumme (Brutto)</td><td align='right'>" .
223
            number_format( $preis, 2, ',', '.' ) . " &euro;</td>";
224
        $items[] =
225
            "<td colspan='4'>Enthaltene MwSt. (19 %):</td><td align='right'>" .
226
            number_format( $mwst, 2, ',', '.' ) . " &euro;</td>";
227
        $text .= "<tr>" . implode( "</tr><tr>", $items ) . "</tr>";
228
        /*$text = $text . "\n___________________________________________________________________________\nGesamtsumme (Brutto): " .
229
        str_pad( numberFormat($preis), 48, " ", STR_PAD_LEFT ) . " Euro\nEnthaltene MwSt. (19 %):" .
230
        str_pad( numberFormat($mwst), 46, " ", STR_PAD_LEFT ) . " Euro";*/
231
        $text .= " </table>";
232
        /*
233
        echo "
234
        <!--
235
        $text
236
        -->";
237
        */
238
        return $text;
239
    }
240
 
241
 
242
 
243
    function createOrderText_html_v2( $BestellID = null, $shops_ID = 1 )
244
    {
245
        $text = "<table><tr><th style='vertical-align:top;align:left;'>Menge:</th><th style='vertical-align:top;align:left;'>Art.Nr.</th><th style='vertical-align:top;align:center;'>Artikelname</th><th style='vertical-align:top;align:right;'>Einzelpreis</th><th style='vertical-align:top;align:right;'>Gesamtpreis</th></tr>";
246
        $result = getArtikelListe( $BestellID, $shops_ID );
247
 
248
        $preis = 0;
249
 
250
        while ( $zeile = mysql_fetch_array( $result ) )
251
        {
252
            //pre($zeile);
253
            $preis += $zeile['Menge'] * $zeile['Preis_pro_Stueck'];
254
            if ( !( ( $zeile["Father"] > -3 ) or ( $zeile["Father"] == "" ) ) and
255
                !( $zeile["artikelStatus"] != 'versand' ) )
256
            {
257
                $items[] = "<td style='vertical-align:top;'>" . $zeile["Menge"] . "</td><td style='vertical-align:top;'>Versand und Zahlung:</td><td style='vertical-align:top;'>" . $zeile["kurzbezeichnung"] ."</td><td style='vertical-align:top;' align='right'>" . number_format( $zeile["Preis_pro_Stueck"],2, ',', '.' ) . " &euro;</td><td style='vertical-align:top;' align='right'>" .   number_format( $zeile["Menge"] * $zeile["Preis_pro_Stueck"], 2, ',', '.' ) . " &euro;</td>";
258
            }
259
            else
260
            {
261
                /* START Artikeloptionen zusammenstellen */
262
                $optionen = "";
263
                /* START Artikeloptionen zusammenstellen */
264
                if ( isset( $zeile["options"] ) )
265
                {
266
                    if ( is_array( $zeile['option'] ) )
267
                    {
268
                        $query_Feature_options =
269
                            "select * from Feature_options where ID = " .
270
                            implode( " or ID = ", $zeile['option'] );
271
                        $result_Feature_options = mysql_query( $query_Feature_options ) or
272
                            mail( "admin@weban.de",
273
                            "Fehler2 in createOrderText.php", mysql_errno() .
274
                            ": " . mysql_error() . "<hr>$query<hr>",
275
                            "from: weban.de" );
276
 
277
 
278
                        while ( $zeile_Feature_options = mysql_fetch_array( $result_Feature_options ) )
279
                        {
280
                            $Feature_options[] = $zeile_Feature_options['Value'];
281
                        }
282
                        $optionen = " (" . implode( ", ", $Feature_options ) .
283
                            ")";
284
                        unset( $Feature_options );
285
                    }
286
                    else
287
                    {
288
                        $optionen = "";
289
                    }
290
                }
291
 
292
                $artikeltext = $zeile['kennung'] . " " . $zeile['kurzbezeichnung'] .
293
                    " " . $optionen;
294
                /* STOP Artikeloptionen zusammenstellen */
295
                $items[] = "<td style='vertical-align:top;'>" . $zeile["Menge"] . "</td><td style='vertical-align:top;'>" . $zeile["kennung"] . "</td><td style='vertical-align:top;'>" . $zeile["kurzbezeichnung"] . " ".$optionen."</td><td style='vertical-align:top;' align='right'>" . number_format( $zeile["Preis_pro_Stueck"],2, ',', '.' ) . " &euro;</td><td style='vertical-align:top;' align='right'>" . number_format( $zeile["Menge"] * $zeile["Preis_pro_Stueck"], 2, ',', '.' ) . " &euro;</td>";
296
            }
297
        }
298
        $mwst = 19;
299
        $mwst = $preis / ( 100 + $mwst ) * $mwst;
300
        $items[] = "<td style='vertical-align:top;' colspan='4'>Gesamtsumme (Brutto)</td><td style='vertical-align:top;' align='right'>" . number_format( $preis, 2, ',', '.' ) . " &euro;</td>";
301
        $items[] = "<td style='vertical-align:top;' colspan='4'>Enthaltene MwSt. (19 %):</td><td style='vertical-align:top;' align='right'>" . number_format( $mwst, 2, ',', '.' ) . " &euro;</td>";
302
        $text .= "<tr>" . implode( "</tr><tr>", $items ) . "</tr>";
303
        /*$text = $text . "\n___________________________________________________________________________\nGesamtsumme (Brutto): " .
304
        str_pad( numberFormat($preis), 48, " ", STR_PAD_LEFT ) . " Euro\nEnthaltene MwSt. (19 %):" .
305
        str_pad( numberFormat($mwst), 46, " ", STR_PAD_LEFT ) . " Euro";*/
306
        $text .= " </table>";
307
        /*
308
        echo "
309
        <!--
310
        $text
311
        -->";
312
        */
313
        return $text;
314
    }
315
 
316
    function getHerstellerFromId( $id )
317
    {
318
 
319
        $sql = "SELECT
320
					Name
321
				FROM
322
					".herstellerDatabase($shops_ID)."
323
				WHERE
324
					ID=" . $id . "
325
				";
326
        die( $sql );
327
        if ( $res = mysql_query( $sql ) )
328
        {
329
            if ( $row = mysql_fetch_assoc( $res ) )
330
            {
331
                return $row['Name'];
332
            }
333
        }
334
        return false;
335
    }
336
?>