Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
 
3
    /**
4
     * @package   php_share
5
     * @author    Lars Tiefland <tiefland@weban.de>
6
     * @copyright 2010 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 439 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   php_share
16
     * @author    Lars Tiefland <tiefland@weban.de>
17
     * @copyright 2010 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: creditcard.interface.php 439 2011-03-10 07:59:29Z tiefland $
21
 
22
    require_once "lieferantenbase.class.php";
23
    require_once "File.php";
24
    require_once "module/shop/html_mails/mail_func.php";
25
 
26
    class Frankana extends LieferantenBase
27
    {
28
        private $filename;
29
        private $k_nr;
30
        public function export( $k_nr )
31
        {
32
            $this->k_nr = $k_nr;
33
            $site = __SITE__;
34
            $text = "";
35
 
36
            if ( serverCheck() === "local." )
37
            {
38
                $basis = "../../" . __SITE__ . "/images/dokumente/";
39
            }
40
            else
41
            {
42
                $basis = "../httpdocs/images/dokumente/";
43
            }
44
            $basis_2 = "bestellexport/" . date( "Y" ) . "/" . date( "m" );
45
 
46
            if ( !file_exists( $basis . $basis_2 ) )
47
            {
48
                mkdir( $basis . $basis_2, 0777, true );
49
            }
50
 
51
            if ( $GLOBALS["INI"]["dbConnect"]["order_db"] )
52
            {
53
                $db = $GLOBALS["INI"]["dbConnect"]["order_db"] . ".";
54
            }
55
            $table = $db . "dokumente";
56
            if ( $this->bestellungen )
57
            {
58
                switch ( $this->bestellungen[0]["lager_id"] )
59
                {
60
                    case 1:
61
                        $to = "bestellung@frankana.de";
62
                        break;
63
                    case 2:
64
                        $to = "ost@frankana.de";
65
                        break;
66
                    case 3:
67
                        $to = "info@freiko.de";
68
                        break;
69
                }
70
                //$to = "tiefland@weban.de";
71
                $subject = "Bestellung von Artikeln über das Lager " . $this->
72
                    bestellungen[0]["lager_name"];
73
 
74
                foreach ( $this->bestellungen as $b_id => $bestellung )
75
                {
76
                    if ( $b_id == 0 )
77
                    {
78
                        $text = $bestellung["text"];
79
                        $zeile = "";
80
                        $bestellung_id = $bestellung["id"];
81
                        $order_id = $bestellung["order_id"];
82
                        $p_zeile = "Bestelldatum: " . date( "d.m.Y H:i" ) .
83
                            "\nBestellnummer: " . $order_id . "\nKundennummer: " .
84
                            $this->k_nr . "\n\n";
85
                    }
86
                    if ( $bestellung["text"] != $text )
87
                    {
88
                        $body = "Kommentar:\n\n";
89
                        $body .= $text . "\n\n";
90
                        $e_body = $body;
91
                        $body .= $p_zeile;
92
                        $this->attach = $basis . create_pdf( $bestellung["order_id"],
93
                            "", "", $body, "LB", generate_LN( $bestellung["id"],
94
                            "LB" ), __SITE__, "", $GLOBALS["INI"]["dbConnect"]["order_db"], true );
95
                        $f_name = "/frankana_export_" . date( "Y-m-d_H-i-s" ) .
96
                            "_" . gen_password( 20 ) . ".txt";
97
                        $this->save_file( $basis . $basis_2 . $f_name, $zeile );
98
                        $e_body .= file_get_contents( $this->filename );
99
                        $this->send_order_mail( $to, $text, $e_body, $bestellung_id,
100
                            $subject );
101
                        $text = $bestellung["text"];
102
                        $zeile = "";
103
                        $bestellung_id = $bestellung["id"];
104
                        $order_id = $bestellung["order_id"];
105
                        $p_zeile = "Bestelldatum: " . date( "d.m.Y H:i" ) .
106
                            "\nBestellnummer: " . $order_id . "\nKundennummer: " .
107
                            $this->k_nr . "\n\n";
108
                    }
109
                    $zeile .= "0;0;" . $text . ";" . $bestellung["menge"] .
110
                        ";" . $this->k_nr . ";" . $bestellung["lieferanten_artnr"] .
111
                        ";\n";
112
                    $p_zeile .= "Menge: " . $bestellung["menge"] . "\n" .
113
                        "Artikelnummer: " . $bestellung["lieferanten_artnr"] .
114
                        "\n";
115
                    if ( $b_id == count( $this->bestellungen ) - 1 )
116
                    {
117
                        $body = "Kommentar:\n\n";
118
                        $body .= $text . "\n\n";
119
                        $e_body = $body;
120
                        $body .= $p_zeile;
121
                        $this->attach = $basis . create_pdf( $bestellung["order_id"],
122
                            "", "", $body, "LB", generate_LN( $bestellung["id"],
123
                            "LB" ), __SITE__, "", $GLOBALS["INI"]["dbConnect"]["order_db"], true );
124
                        $f_name = "/frankana_export_" . date( "Y-m-d_H-i-s" ) .
125
                            "_" . gen_password( 20 ) . ".txt";
126
                        $this->save_file( $basis . $basis_2 . $f_name, $zeile );
127
                        $e_body .= file_get_contents( $this->filename );
128
                        $this->send_order_mail( $to, $text, $e_body, $bestellung_id,
129
                            $subject );
130
                    }
131
                    save_document( $basis_2 . $f_name, $bestellung["id"], $table,
132
                        "artikel_to_lieferantenbestellung" );
133
                    updateBetellung( $bestellung["id"] );
134
                }
135
            }
136
        }
137
 
138
        function send_order_mail( $to, $text, $body, $bestellung_id, $subject )
139
        {
140
            $extra["shops_ID"] = $GLOBALS["INI"]["shops_ID"];
141
            $extra["site"] = __SITE__;
142
            $extra["headers"] = array( "From" => "info@pieper-freizeit.de" );
143
 
144
            $extra["files"] = array( $this->attach );
145
 
146
            send_email( $to, $subject, $body, $extra );
147
        }
148
        function save_file( $f_name, $zeile )
149
        {
150
            $this->filename = $f_name;
151
            $file = new File( $this->filename, "w" );
152
            $file->write( $this->filename, "SD-061057;\nFLEVER: SD.02.01\nFLDNAME: KZ_DS_BIM\nFLDTYP: NUM()\nFLDCMT: DB_TYPE :FT_SHORT\nFLDNAME: bel_nr\nFLDTYP: NUM()\nFLDCMT: DB_TYPE :FT_LONG\nFLDNAME: Bel_refnr\nFLDTYP: NUM()\nFLDCMT: DB_TYPE :FT_STRING\nFLDNAME: pos_bestellme\nFLDTYP: NUM()\nFLDCMT: DB_TYPE :FT_DOUBLE\nFLDNAME: kdn_kontonr\nFLDTYP: NUM()\nFLDCMT: DB_TYPE :FT_LONG\nFLDNAME: art_nr\nFLDTYP: STR(WIN)\nFLDCMT: DB_TYPE :FT_STRING\n" );
153
            $file->write( $this->filename, "DATEN:\n" );
154
            $file->write( $this->filename, $zeile );
155
            $file->close( $this->filename, "w" );
156
        }
157
    }
158
?>