| 1 |
lars |
1 |
<?
|
|
|
2 |
header( 'Content-Type: text/x-csv' );
|
|
|
3 |
header( 'Content-Disposition: attachment; filename="logistik.txt"' );
|
|
|
4 |
header( 'Expires: 0' );
|
|
|
5 |
//header('Content-Type: application/editor');
|
|
|
6 |
//$filename="logistik"; //.date("Ymd-His");
|
|
|
7 |
//$ext="txt";
|
|
|
8 |
//header('Content-Disposition: inline; filename="' . $filename . '.' . $ext . '"');
|
|
|
9 |
//header('Expires: 0');
|
|
|
10 |
//header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
|
|
11 |
//header('Pragma: public');
|
|
|
12 |
|
|
|
13 |
define( "modul_name", "Warenwirtschaft" );
|
|
|
14 |
define( "tool_name", "bestellung" );
|
|
|
15 |
include "../Online-Shop/connect2.php";
|
|
|
16 |
$POOL_VERTRAG_Inland = 1;
|
|
|
17 |
$POOL_VERTRAG_Ausland = 53;
|
|
|
18 |
if ( $web_rechte[modul_name]["bestellexport_dhl"]["dhl"] )
|
|
|
19 |
{
|
|
|
20 |
$inhalt = explode( ";", $web_rechte[modul_name]["bestellexport_dhl"]["dhl"] );
|
|
|
21 |
foreach ( $inhalt as $row )
|
|
|
22 |
{
|
|
|
23 |
$zeile = explode( ":", $row );
|
|
|
24 |
$name = $zeile[0];
|
|
|
25 |
if ( $name == "POOL_VERTRAG" )
|
|
|
26 |
{
|
|
|
27 |
$POOL_VERTRAG_Inland = $zeile[1];
|
|
|
28 |
$POOL_VERTRAG_Ausland = $zeile[2];
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
$query = "
|
| 2 |
lars |
35 |
select
|
|
|
36 |
b.ID as POOL_REFNR,
|
|
|
37 |
b.shops_ID as POOL_V_ABS_REFNR,
|
|
|
38 |
substring(b.Bemerkung,locate('\n',b.Bemerkung)+1) as POOL_V_ABS_BEMERKUNG,
|
|
|
39 |
'464338' as POOL_V_MAND_REFNR,
|
|
|
40 |
if (b.liefer_Land!='',(if (b.liefer_Land='Deutschland','$POOL_VERTRAG_Inland','$POOL_VERTRAG_Ausland')),(if (l.Land='Deutschland','$POOL_VERTRAG_Inland','$POOL_VERTRAG_Ausland')))
|
|
|
41 |
as POOL_VERTRAG,
|
|
|
42 |
if (b.liefer_Str_Nr!='',b.liefer_Str_Nr,l.Hausnummer) as POOL_EMPF_HAUSNUMMER,
|
|
|
43 |
floor(a.short_line_2) as POOL_V_PRODUKT_CN,
|
|
|
44 |
a.short_line_2 as POOL_V_xxxxx,
|
|
|
45 |
'EUR' as POOL_V_NN_WAEHRUNG,
|
|
|
46 |
'EUR' as POOL_WERT_WAEHRUNG,
|
|
|
47 |
l.ID as POOL_EMPF_REFNR,
|
|
|
48 |
if (b.liefer_Name!='',(if (b.liefer_Firma='',if(b.liefer_Vorname!='',concat(b.liefer_Vorname,' ', b.liefer_Name),b.liefer_Name),b.liefer_Firma)),(if (l.Name2='',trim(concat(l.Vorname,' ',l.Name1)),l.Name2))) as POOL_EMPF_NAME1,
|
|
|
49 |
if (b.liefer_Firma!='',b.liefer_Name,(if(l.Name2!='',if(l.Vorname!='',concat(l.Vorname,' ',l.Name1),l.Name1),''))) as POOL_EMPF_NAME2,
|
|
|
50 |
if (b.liefer_PLZ!='',b.liefer_PLZ,l.PLZ) as POOL_EMPF_PLZ,
|
|
|
51 |
if (b.liefer_Ort!='',b.liefer_Ort,l.ORT) as POOL_EMPF_ORT,
|
|
|
52 |
if (b.liefer_Strasse!='',b.liefer_Strasse,l.Strasse) as POOL_EMPF_STRASSE,
|
|
|
53 |
if (b.liefer_Land!='',b.liefer_Land,l.Land) as POOL_EMPF_LANDCODE,
|
|
|
54 |
l.E_Mail as POOL_EMPF_MAIL,
|
|
|
55 |
ab.ID as ID,
|
|
|
56 |
IF (ab.Bezeichnung LIKE '%Nachnahme%', CONCAT('134=',b.gesamtsumme_buffer),'') as POOL_V_EXTRASLST,
|
|
|
57 |
l.Telefon as POOL_EMPF_TEL
|
|
|
58 |
|
|
|
59 |
from
|
|
|
60 |
Bestellung AS b,
|
|
|
61 |
artikel_to_Bestellung AS ab,
|
|
|
62 |
artikel AS a,
|
|
|
63 |
Logins AS l
|
|
|
64 |
where
|
|
|
65 |
(a.Father =-3)
|
|
|
66 |
and
|
|
|
67 |
(a.ID=ab.artikel)
|
|
|
68 |
and
|
|
|
69 |
(ab.Bestellung = b.ID)
|
|
|
70 |
and
|
|
|
71 |
(b.Login = l.ID)
|
|
|
72 |
and
|
|
|
73 |
(b.Language = a.Language)
|
|
|
74 |
";
|
| 1 |
lars |
75 |
if ( $_GET[time] )
|
|
|
76 |
{
|
|
|
77 |
$query .= " and (ab.exported = '" . $_GET[time] . "')";
|
|
|
78 |
}
|
|
|
79 |
else
|
|
|
80 |
{
|
|
|
81 |
$query .= " and (ab.status = 'freigegeben')";
|
|
|
82 |
}
|
|
|
83 |
$firstline = false;
|
|
|
84 |
$trenner = "|";
|
|
|
85 |
$result = mysql_query( $query ) or die( mysql_errno() . ": " .
|
|
|
86 |
mysql_error() . "<hr>$query<hr>" );
|
|
|
87 |
|
|
|
88 |
$elements = array();
|
|
|
89 |
|
|
|
90 |
while ( $zeile = mysql_fetch_assoc( $result ) )
|
|
|
91 |
{
|
|
|
92 |
$elements[] = $zeile[ID];
|
|
|
93 |
unset( $zeile[ID] );
|
|
|
94 |
|
|
|
95 |
if ( $firstline )
|
|
|
96 |
{
|
|
|
97 |
echo implode( array_keys( $zeile ), $trenner ) . "\n\n ";
|
|
|
98 |
$firstline = false;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
$result_gesBetrag = mysql_query( "
|
| 2 |
lars |
102 |
select
|
|
|
103 |
artikel_to_Bestellung.*,
|
|
|
104 |
(Menge * Preis_pro_Stueck) as gesBetrag,
|
| 1 |
lars |
105 |
(Menge * gewicht) as gesGewicht,
|
| 2 |
lars |
106 |
artikel.kurzbezeichnung,
|
|
|
107 |
artikel.Father
|
|
|
108 |
from
|
|
|
109 |
artikel_to_Bestellung,
|
|
|
110 |
artikel
|
|
|
111 |
where
|
|
|
112 |
artikel_to_Bestellung.Bestellung=$zeile[POOL_REFNR]
|
|
|
113 |
and
|
|
|
114 |
artikel_to_Bestellung.artikel = artikel.ID
|
|
|
115 |
and
|
|
|
116 |
artikel.Language = 'DE'
|
|
|
117 |
order by artikel.Father desc
|
|
|
118 |
" ) or die( mysql_errno() . ": " . mysql_error() . "<hr>$query<hr>" );
|
| 1 |
lars |
119 |
$gesBetrag = 0;
|
|
|
120 |
$gesGewicht = 0;
|
|
|
121 |
$buffer = array();
|
|
|
122 |
while ( $zeile_gesBetrag = mysql_fetch_assoc( $result_gesBetrag ) )
|
|
|
123 |
{
|
|
|
124 |
if ( $zeile_gesBetrag["Bezeichnung"] )
|
|
|
125 |
{
|
|
|
126 |
$zeile_gesBetrag["kurzbezeichnung"] = $zeile_gesBetrag["Bezeichnung"];
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
if ( $zeile_gesBetrag["Father"] > -3 )
|
|
|
130 |
{
|
|
|
131 |
$buffer[] = $zeile_gesBetrag["Menge"] . "x " . strip_tags( $zeile_gesBetrag["kurzbezeichnung"] );
|
|
|
132 |
}
|
|
|
133 |
$gesBetrag += $zeile_gesBetrag["gesBetrag"];
|
|
|
134 |
$gesGewicht += $zeile_gesBetrag["gesGewicht"];
|
|
|
135 |
}
|
|
|
136 |
$gesBetrag = number_format( $gesBetrag, 2, ',', '.' );
|
|
|
137 |
$gesGewicht = number_format( $gesGewicht, 2, ',', '.' );
|
|
|
138 |
$zeile["POOL_EMPF_BEMERKUNG"] = implode( ", ", $buffer ) . "|" . $gesBetrag .
|
|
|
139 |
"|" . $gesGewicht;
|
|
|
140 |
|
|
|
141 |
eval( "\$zeile[POOL_V_EXTRASLST]=\"$zeile[POOL_V_EXTRASLST]\";" );
|
|
|
142 |
|
|
|
143 |
/*
|
| 2 |
lars |
144 |
$translate['Deutschland'] ="DE";
|
|
|
145 |
$translate['Niederlande'] ="NL";
|
|
|
146 |
$translate['Österreich'] ="AT";
|
|
|
147 |
$translate['Belgien'] ="BE";
|
|
|
148 |
$translate['Luxemburg'] ="LU";
|
|
|
149 |
$translate['Dänemark'] ="DK";
|
|
|
150 |
$translate['Schweiz'] ="CH";
|
|
|
151 |
$translate['Frankreich'] ="FR";
|
|
|
152 |
$translate['Großbritannien'] ="GB";
|
|
|
153 |
$translate['Italien'] ="IT";
|
|
|
154 |
$translate['Spanien'] ="ES";
|
|
|
155 |
$translate['Portugal'] ="PT";
|
|
|
156 |
$translate['Schweden'] ="SE";
|
|
|
157 |
$translate['Finnland'] ="FI";
|
|
|
158 |
$translate['Norwegen'] ="NO";
|
|
|
159 |
$translate['Irland'] ="IE";
|
|
|
160 |
$translate['Griechenland'] ="GR";
|
|
|
161 |
$translate['Nederland'] ="NL";
|
| 1 |
lars |
162 |
$zeile[POOL_EMPF_LANDCODE]=$translate[$zeile[POOL_EMPF_LANDCODE]];
|
|
|
163 |
*/
|
|
|
164 |
|
|
|
165 |
echo preg_replace( "/[\r\n]/", " ", implode( $zeile, $trenner ) ) .
|
|
|
166 |
"\n";
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
if ( ( count( $elements ) > 0 ) and ( !$_GET[time] ) )
|
|
|
170 |
{
|
|
|
171 |
$query =
|
|
|
172 |
"update artikel_to_Bestellung set exported=NOW(), status='versand' where ID=" .
|
|
|
173 |
implode( $elements, " or ID=" ) . "";
|
|
|
174 |
$result = mysql_query( $query ) or die( mysql_errno() . ": " .
|
|
|
175 |
mysql_error() . "<hr>$query<hr>" );
|
|
|
176 |
}
|
|
|
177 |
?>
|