Subversion-Projekte lars-tiefland.content-management

Revision

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