| 1 |
lars |
1 |
<?php
|
|
|
2 |
//$Id: rechnungsbuch.php 3931 2011-09-16 08:17:57Z tiefland $
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* @author Patirck Lautsch <lautsch@weban.de>
|
|
|
6 |
* @copyright 2010 Webagentur Niewerth
|
|
|
7 |
* @package Content-management
|
|
|
8 |
* @version $Rev: 3931 $
|
|
|
9 |
* @license propietary
|
|
|
10 |
* @filesource
|
|
|
11 |
*
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
*
|
|
|
16 |
* @author Patirck Lautsch <lautsch@weban.de>
|
|
|
17 |
* @copyright 2010 Webagentur Niewerth
|
|
|
18 |
* @package Content-management
|
|
|
19 |
*/
|
|
|
20 |
// deutsche Umgebung
|
|
|
21 |
setlocale( LC_ALL, "de_DE" );
|
|
|
22 |
////////////////////
|
|
|
23 |
|
|
|
24 |
// Connect-Datei einbinden
|
|
|
25 |
define( "modul_name", "Warenwirtschaft" );
|
|
|
26 |
define( "tool_name", "bestellung" );
|
|
|
27 |
define( "F_NAME", basename( $_SERVER["PHP_SELF"] ) );
|
|
|
28 |
require_once "../Online-Shop/connect2.php";
|
|
|
29 |
require_once "module/functions.common.php";
|
|
|
30 |
//////////////////////////
|
|
|
31 |
|
|
|
32 |
// Start der Session
|
|
|
33 |
session_start();
|
|
|
34 |
////////////////////
|
|
|
35 |
|
|
|
36 |
// Smarty Initalisierung
|
|
|
37 |
require_once "Weban_Smarty.class.php";
|
|
|
38 |
require_once "includes/rechnung/rechnungsbuch.function.php";
|
|
|
39 |
$GLOBALS["ui"] = new Weban_Smarty();
|
|
|
40 |
$GLOBALS["ui"]->conifg_dir = SMARTY_DIR;
|
|
|
41 |
$GLOBALS["ui"]->template_dir = "templates/";
|
|
|
42 |
$GLOBALS["ui"]->compile_dir = $_SERVER["DOCUMENT_ROOT"] . "/templates_c";
|
|
|
43 |
$GLOBALS["ui"]->compile_id = "Warenwirtschaft|best_manu";
|
|
|
44 |
$GLOBALS["ui"]->use_sub_dirs = true;
|
|
|
45 |
$GLOBALS["ui"]->compile_check = true;
|
|
|
46 |
$GLOBALS["ui"]->assign( "eingabefelder", $eingabefelder );
|
|
|
47 |
$GLOBALS["ui"]->assign( "webs", $webs );
|
|
|
48 |
$GLOBALS["ui"]->assign("site", $site);
|
|
|
49 |
////////////////////////
|
|
|
50 |
|
|
|
51 |
// ME: Muss der Bezahlstatus gespeichert werden?
|
|
|
52 |
if($_POST['action'] == "save_bezahlstatus") {
|
|
|
53 |
save_bezahlstatus($_POST['status']);
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
// Hole alle Ersteller und übergebe diese an Smarty
|
|
|
57 |
$sql = '
|
|
|
58 |
SELECT
|
|
|
59 |
erstellt_von
|
|
|
60 |
FROM
|
|
|
61 |
rechnung
|
|
|
62 |
GROUP BY
|
|
|
63 |
erstellt_von
|
|
|
64 |
;';
|
|
|
65 |
|
|
|
66 |
$result = mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error
|
|
|
67 |
() . '<hr />' . $sql );
|
|
|
68 |
|
|
|
69 |
for ( $i = 0; $row = mysql_fetch_assoc( $result ); $i++ )
|
|
|
70 |
{
|
|
|
71 |
$ersteller2[$i] = $row['erstellt_von'];
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
$GLOBALS["ui"]->assign( "ersteller", $ersteller2 );
|
|
|
75 |
///////////////////////////////////////////////////
|
|
|
76 |
|
|
|
77 |
// Hole alle Shops und übergebe diese an Smarty
|
|
|
78 |
$sql = '
|
|
|
79 |
SELECT
|
|
|
80 |
ID AS id,
|
|
|
81 |
Name AS name
|
|
|
82 |
FROM
|
|
|
83 |
shops
|
|
|
84 |
;';
|
|
|
85 |
$result = mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error
|
|
|
86 |
() . '<hr />' . $sql );
|
|
|
87 |
|
|
|
88 |
$shops["id"][] = "";
|
|
|
89 |
$shops["name"][] = "--- alle ---";
|
|
|
90 |
while ( $row = mysql_fetch_assoc( $result ) )
|
|
|
91 |
{
|
|
|
92 |
$shops["id"][] = $row['id'];
|
|
|
93 |
$shops["name"][] = $row["name"];
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
$GLOBALS["ui"]->assign( "shops", $shops );
|
|
|
97 |
///////////////////////////////////////////////
|
|
|
98 |
|
|
|
99 |
// Zeitraum
|
|
|
100 |
$zeitraum = array( 0 => strftime( "%B %Y" ), 1 => strftime( "%B %Y",
|
|
|
101 |
strtotime( "-1 month" ) ), 2 => strftime( "%B %Y", strtotime( "-2 months" ) ),
|
|
|
102 |
3 => strftime( "%B %Y", strtotime( "-3 months" ) ), 4 => strftime( "%B %Y",
|
|
|
103 |
strtotime( "-4 months" ) ), 5 => strftime( "%B %Y", strtotime( "-5 months" ) ),
|
|
|
104 |
6 => strftime( "%B %Y", strtotime( "-6 months" ) ), 7 => strftime( "%B %Y",
|
|
|
105 |
strtotime( "-7 months" ) ), 8 => strftime( "%B %Y", strtotime( "-8 months" ) ),
|
|
|
106 |
9 => strftime( "%B %Y", strtotime( "-9 months" ) ), 10 => strftime( "%B %Y",
|
|
|
107 |
strtotime( "-10 months" ) ), 11 => strftime( "%B %Y", strtotime( "-11 months" ) ),
|
|
|
108 |
12 => strftime( "%B %Y", strtotime( "-12 months" ) ), 13 => strftime
|
|
|
109 |
( "%B %Y", strtotime( "-13 months" ) ), 14 => "--- alle ---", );
|
|
|
110 |
|
|
|
111 |
$GLOBALS["ui"]->assign( "zeitraum", $zeitraum );
|
|
|
112 |
///////////
|
|
|
113 |
|
|
|
114 |
// Übergebe ausgewählte Formulardaten an Smarty zur Vorauswal
|
|
|
115 |
$GLOBALS["ui"]->assign( "cbErsteller", $_POST['cbErsteller'] );
|
|
|
116 |
$GLOBALS["ui"]->assign( "cbShop", $_POST['cbShop'] );
|
|
|
117 |
$GLOBALS["ui"]->assign( "cbBezahlstatus", $_POST['cbBezahlstatus'] );
|
|
|
118 |
$GLOBALS["ui"]->assign( "cbKdNr", $_POST['cbKdNr'] );
|
|
|
119 |
$GLOBALS["ui"]->assign( "cbKunde", $_POST['cbKunde'] );
|
|
|
120 |
$GLOBALS["ui"]->assign( "cbFirma", $_POST['cbFirma'] );
|
|
|
121 |
$GLOBALS["ui"]->assign( "cbMwSt7", $_POST['cbMwSt7'] );
|
|
|
122 |
$GLOBALS["ui"]->assign( "cbMwSt19", $_POST['cbMwSt19'] );
|
|
|
123 |
$GLOBALS["ui"]->assign( "cbNettobetrag", $_POST['cbNettobetrag'] );
|
|
|
124 |
$GLOBALS["ui"]->assign( "cbMwStBefreiung", $_POST['cbMwStBefreiung'] );
|
|
|
125 |
$GLOBALS["ui"]->assign( "cbUStIdNr", $_POST['cbUStIdNr'] );
|
|
|
126 |
$GLOBALS["ui"]->assign( "cbBestellnummer", $_POST['cbBestellnummer'] );
|
|
|
127 |
$GLOBALS["ui"]->assign( "va_zeitraum", $_POST['zeitraum'] );
|
|
|
128 |
|
|
|
129 |
if($_POST['txtFaellig']) {
|
|
|
130 |
$txtFaellig = strtotime( $_POST['txtFaellig'] ) + 86399;
|
|
|
131 |
$GLOBALS["ui"]->assign( "txtFaellig", strtotime( $_POST['txtFaellig'] ) + 86399 );
|
|
|
132 |
}else{
|
|
|
133 |
//$GLOBALS["ui"]->assign( "txtFaellig", 0);
|
|
|
134 |
}
|
|
|
135 |
if(is_array( $_POST['msZahlart'] )) {
|
|
|
136 |
$GLOBALS["ui"]->assign( "msZahlart", $_POST['msZahlart'] );
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
/////////////////////////////////////////////////////////////
|
|
|
140 |
// ME: alle Zahlungsarten holen, wenn es die Tabelle dazu gibt.
|
|
|
141 |
if(table_exists('zahlungsarten',$webs["datenbank"])==true) {
|
|
|
142 |
$zahlungsarten = getZahlungsarten();
|
|
|
143 |
$GLOBALS["ui"]->assign("zahlungsarten",$zahlungsarten);
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
// WHERE-Klausel zusammenbauen für die Rechnungsausgabe
|
|
|
148 |
$post = $_POST;
|
|
|
149 |
|
|
|
150 |
if ( !empty( $post['ersteller'] ) )
|
|
|
151 |
{
|
|
|
152 |
$where_klausel .= " AND erstellt_von = '" . $post['ersteller'] .
|
|
|
153 |
"' ";
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
if ( !empty( $post['shops_id'] ) )
|
|
|
157 |
{
|
|
|
158 |
$where_klausel .= " AND shops_id = '" . $post['shops_id'] . "' ";
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
if ( !empty( $post['kd_nr'] ) )
|
|
|
162 |
{
|
|
|
163 |
$where_klausel .= " AND kundennr = '" . $post['kd_nr'] . "' ";
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
$zselect="";
|
|
|
167 |
$zfrom="";
|
|
|
168 |
$zorder_by="";
|
|
|
169 |
if ( isset($web_rechte["Warenwirtschaft"]["rechnungsbuch"]["zahlungsziel"]) ) {
|
|
|
170 |
if ( !empty( $post['txtFaellig'] ) )
|
|
|
171 |
{
|
|
|
172 |
$where_klausel .= " AND zahlungsziel != '' ";
|
|
|
173 |
}
|
|
|
174 |
if(table_exists('zahlungsarten',$webs['datenbank'])) {
|
|
|
175 |
$zselect = " ,z.* ";
|
|
|
176 |
$zfrom = " left join zahlungsarten z on r.zahlungsart_id = z.id";
|
|
|
177 |
$zorder_by = ", z.name ";
|
|
|
178 |
}
|
|
|
179 |
if(is_array( $_POST['msZahlart'] )) {
|
|
|
180 |
foreach($_POST['msZahlart'] as $key => $val) {
|
|
|
181 |
if($val>0) {
|
|
|
182 |
$wh[] = " r.zahlungsart_id = ".$val."";
|
|
|
183 |
}
|
|
|
184 |
}
|
|
|
185 |
if(is_array($wh)) {
|
|
|
186 |
$wh_impl = implode(" or ", $wh);
|
|
|
187 |
$where_klausel .= " AND ( ".$wh_impl." )";
|
|
|
188 |
$zorder_by = ", z.name ";
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
//if ( isset( $post['zeitraum'] ) )
|
|
|
195 |
|
|
|
196 |
{
|
|
|
197 |
// ### ZEITFILTER HERSTELLEN ###
|
|
|
198 |
$filter_zeit1 = 'erstellt_am';
|
|
|
199 |
switch ( $post['zeitraum'] )
|
|
|
200 |
{
|
|
|
201 |
case 14:
|
|
|
202 |
break;
|
|
|
203 |
case 0: // lfd. Monat
|
|
|
204 |
default:
|
|
|
205 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(NOW(),\"%Y%m\")";
|
|
|
206 |
$zeit_filter2 = 'NOW()';
|
|
|
207 |
break;
|
|
|
208 |
case 1: // letzter Monat
|
|
|
209 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 1 MONTH),\"%Y%m\")";
|
|
|
210 |
$zeit_filter2 = 'NOW() - INTERVAL 1 MONTH';
|
|
|
211 |
break;
|
|
|
212 |
case 2: // vorletzter Monat
|
|
|
213 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 2 MONTH),\"%Y%m\")";
|
|
|
214 |
$zeit_filter2 = 'NOW() - INTERVAL 2 MONTH';
|
|
|
215 |
break;
|
|
|
216 |
case 3: // vorletzter Monat
|
|
|
217 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 3 MONTH),\"%Y%m\")";
|
|
|
218 |
$zeit_filter2 = 'NOW() - INTERVAL 3 MONTH';
|
|
|
219 |
break;
|
|
|
220 |
case 4: // vorletzter Monat
|
|
|
221 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 4 MONTH),\"%Y%m\")";
|
|
|
222 |
$zeit_filter2 = 'NOW() - INTERVAL 4 MONTH';
|
|
|
223 |
break;
|
|
|
224 |
case 5: // vorletzter Monat
|
|
|
225 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 5 MONTH),\"%Y%m\")";
|
|
|
226 |
$zeit_filter2 = 'NOW() - INTERVAL 5 MONTH';
|
|
|
227 |
break;
|
|
|
228 |
case 6: // vorletzter Monat
|
|
|
229 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 6 MONTH),\"%Y%m\")";
|
|
|
230 |
$zeit_filter2 = 'NOW() - INTERVAL 6 MONTH';
|
|
|
231 |
break;
|
|
|
232 |
case 7: // vorletzter Monat
|
|
|
233 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 7 MONTH),\"%Y%m\")";
|
|
|
234 |
$zeit_filter2 = 'NOW() - INTERVAL 7 MONTH';
|
|
|
235 |
break;
|
|
|
236 |
case 8: // vorletzter Monat
|
|
|
237 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 8 MONTH),\"%Y%m\")";
|
|
|
238 |
$zeit_filter2 = 'NOW() - INTERVAL 8 MONTH';
|
|
|
239 |
break;
|
|
|
240 |
case 9: // vorletzter Monat
|
|
|
241 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 9 MONTH),\"%Y%m\")";
|
|
|
242 |
$zeit_filter2 = 'NOW() - INTERVAL 9 MONTH';
|
|
|
243 |
break;
|
|
|
244 |
case 10: // vorletzter Monat
|
|
|
245 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 10 MONTH),\"%Y%m\")";
|
|
|
246 |
$zeit_filter2 = 'NOW() - INTERVAL 10 MONTH';
|
|
|
247 |
break;
|
|
|
248 |
case 11: // vorletzter Monat
|
|
|
249 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 11 MONTH),\"%Y%m\")";
|
|
|
250 |
$zeit_filter2 = 'NOW() - INTERVAL 11 MONTH';
|
|
|
251 |
break;
|
|
|
252 |
case 12: // vorletzter Monat
|
|
|
253 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 12 MONTH),\"%Y%m\")";
|
|
|
254 |
$zeit_filter2 = 'NOW() - INTERVAL 12 MONTH';
|
|
|
255 |
break;
|
|
|
256 |
case 13: // vorletzter Monat
|
|
|
257 |
$time_filter = " and date_format(" . $filter_zeit1 . ",\"%Y%m\") = date_format(date_sub(NOW(), INTERVAL 13 MONTH),\"%Y%m\")";
|
|
|
258 |
$zeit_filter2 = 'NOW() - INTERVAL 13 MONTH';
|
|
|
259 |
break;
|
|
|
260 |
}
|
|
|
261 |
$where_klausel .= $time_filter;
|
|
|
262 |
}
|
|
|
263 |
/////////////////////////////////////////////////////
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
// Hole alle Rechnungen für die Rechnungsausgabe
|
|
|
267 |
$sql = '
|
|
|
268 |
SELECT
|
|
|
269 |
r.*
|
|
|
270 |
'.$zselect.'
|
|
|
271 |
FROM
|
|
|
272 |
rechnung r
|
|
|
273 |
'.$zfrom.'
|
|
|
274 |
WHERE
|
|
|
275 |
1 = 1
|
|
|
276 |
' . $where_klausel . '
|
|
|
277 |
ORDER BY
|
|
|
278 |
rechnungsnummer DESC '.$zorder_by.'
|
|
|
279 |
;';
|
|
|
280 |
|
|
|
281 |
$result = mysql_query( $sql ) or die( mysql_errno() . ': ' . mysql_error
|
|
|
282 |
() . '<hr />' . $sql );
|
|
|
283 |
|
|
|
284 |
$temp = explode( "redaktion.", $_SERVER['SERVER_NAME'] );
|
|
|
285 |
$domain = $temp[1];
|
|
|
286 |
|
|
|
287 |
for ( $i = 0; $row = mysql_fetch_assoc( $result ); $i++ )
|
|
|
288 |
{
|
|
|
289 |
if(strlen( $row['zahlungsziel'])>0) {
|
|
|
290 |
$zahlungsziel = unserialize($row['zahlungsziel']);
|
|
|
291 |
|
|
|
292 |
if($txtFaellig) {
|
|
|
293 |
if($zahlungsziel['ziel']>$txtFaellig) {
|
|
|
294 |
continue;
|
|
|
295 |
}
|
|
|
296 |
}
|
|
|
297 |
$rec[$i]['zahlungsziel'] = $zahlungsziel['ziel'];
|
|
|
298 |
$rec[$i]['now'] = time();
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
if($row['zahlungsart_id']>0 and $row['name']) {
|
|
|
302 |
$rec[$i]['zahlungsart'] = $row['name'];
|
|
|
303 |
}else{
|
|
|
304 |
$rec[$i]['zahlungsart'] = "n/a";
|
|
|
305 |
}
|
|
|
306 |
$rec[$i]['rechnungsnummer'] = $row['rechnungsnummer'];
|
|
|
307 |
$rec[$i]['rechnungsnummerLupe'] = 'http://' . $domain .
|
|
|
308 |
'/images/dokumente/R' . $rec[$i]['rechnungsnummer'] . '.pdf';
|
|
|
309 |
$rec[$i]['rechnungsnummerLink'] = "http://redaktion." . $domain .
|
|
|
310 |
"/Warenwirtschaft/bestellungen.php?Bestellung=" . $row['bestellung'];
|
|
|
311 |
$rec[$i]['erstellt_am'] = $row['erstellt_am'];
|
|
|
312 |
$rec[$i]['bruttobetrag'] = number_format( $row['bruttobetrag'], 2,
|
|
|
313 |
',', '.' );
|
|
|
314 |
$rec[$i]['erstellt_von'] = $row['erstellt_von'];
|
|
|
315 |
if ( $row['shops_id'] )
|
|
|
316 |
{
|
|
|
317 |
$rec[$i]['shop'] = getShop( $row['shops_id'] );
|
|
|
318 |
}
|
|
|
319 |
else
|
|
|
320 |
{
|
|
|
321 |
$rec[$i]["shop"] = $row["shop"];
|
|
|
322 |
}
|
|
|
323 |
$rec[$i]['kundennr'] = $row['kundennr'];
|
|
|
324 |
$rec[$i]['kunde'] = $row['kunde'];
|
|
|
325 |
$rec[$i]['firma'] = $row['firma'];
|
|
|
326 |
$rec[$i]['mwst_7'] = number_format( $row['mwst_7'], 2, ',', '.' );
|
|
|
327 |
$rec[$i]['mwst_19'] = number_format( $row['mwst_19'], 2, ',', '.' );
|
|
|
328 |
$rec[$i]['nettobetrag'] = number_format( $row['nettobetrag'], 2, ',',
|
|
|
329 |
'.' );
|
|
|
330 |
$rec[$i]['mwst_befreiung'] = $row['mwst_befreiung'];
|
|
|
331 |
$rec[$i]['ustid_nr'] = $row['ustid_nr'];
|
|
|
332 |
$rec[$i]['bestellung'] = $row['bestellung'];
|
|
|
333 |
|
|
|
334 |
// Zählen für die Summenfunktionen
|
|
|
335 |
$nettobetragGesamt += $row['nettobetrag'];
|
|
|
336 |
$bruttobetragGesamt += $row['bruttobetrag'];
|
|
|
337 |
$mwst_7Gesamt += $row['mwst_7'];
|
|
|
338 |
$mwst_19Gesamt += $row['mwst_19'];
|
|
|
339 |
|
|
|
340 |
// Bezahlstatus Sonderfall
|
|
|
341 |
// ME: History des Bezahlstatus aufbauen und an smarty übergeben
|
|
|
342 |
$rec[$i]['bezahlstatus_history'] = getRechnungHistory($row);
|
|
|
343 |
|
|
|
344 |
if ( $row['storniert'] )
|
|
|
345 |
{
|
|
|
346 |
$rec[$i]['bezahlstatus'] = 'storniert';
|
|
|
347 |
}
|
|
|
348 |
else
|
|
|
349 |
{
|
|
|
350 |
if ( $row['bezahlt_am'] > 0 )
|
|
|
351 |
{
|
|
|
352 |
$rec[$i]['bezahlstatus'] = 'bezahlt';
|
|
|
353 |
}
|
|
|
354 |
else
|
|
|
355 |
{
|
|
|
356 |
if ( $row['3_mahnung_nr'] > 0 )
|
|
|
357 |
{
|
|
|
358 |
$rec[$i]['bezahlstatus'] = '3. Mahnung';
|
|
|
359 |
} elseif ( $row['2_mahnung_nr'] > 0 )
|
|
|
360 |
{
|
|
|
361 |
$rec[$i]['bezahlstatus'] = '2. Mahnung';
|
|
|
362 |
} elseif ( $row['1_mahnung_nr'] > 0 )
|
|
|
363 |
{
|
|
|
364 |
$rec[$i]['bezahlstatus'] = '1. Mahnung';
|
|
|
365 |
}
|
|
|
366 |
else
|
|
|
367 |
{
|
|
|
368 |
$rec[$i]['bezahlstatus'] = 'offen';
|
|
|
369 |
}
|
|
|
370 |
}
|
|
|
371 |
}
|
|
|
372 |
//////////////////////////
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
// Gesamtsumme übergeben
|
|
|
376 |
$nettobetragGesamt = number_format( $nettobetragGesamt, 2, ',', '.' );
|
|
|
377 |
$bruttobetragGesamt = number_format( $bruttobetragGesamt, 2, ',', '.' );
|
|
|
378 |
$mwst_7Gesamt = number_format( $mwst_7Gesamt, 2, ',', '.' );
|
|
|
379 |
$mwst_19Gesamt = number_format( $mwst_19Gesamt, 2, ',', '.' );
|
|
|
380 |
|
|
|
381 |
|
|
|
382 |
if ( $bruttobetragGesamt > 0 || $mwst_7Gesamt > 0 || $mwst_19Gesamt > 0 ||
|
|
|
383 |
$nettobetragGesamt > 0 )
|
|
|
384 |
{
|
|
|
385 |
|
|
|
386 |
$rec[$i]['rechnungsnummer'] = "<b>Gesamt:</b>";
|
|
|
387 |
$rec[$i]['erstellt_am'] = " ";
|
|
|
388 |
$rec[$i]['bruttobetrag'] = "<b>" . $bruttobetragGesamt . "</b>";
|
|
|
389 |
$rec[$i]['erstellt_von'] = " ";
|
|
|
390 |
$rec[$i]['shop'] = " ";
|
|
|
391 |
$rec[$i]['kundennr'] = " ";
|
|
|
392 |
$rec[$i]['kunde'] = " ";
|
|
|
393 |
$rec[$i]['firma'] = " ";
|
|
|
394 |
$rec[$i]['mwst_7'] = "<b>" . $mwst_7Gesamt . "</b>";
|
|
|
395 |
$rec[$i]['mwst_19'] = "<b>" . $mwst_19Gesamt . "</b>";
|
|
|
396 |
$rec[$i]['nettobetrag'] = "<b>" . $nettobetragGesamt . "</b>";
|
|
|
397 |
$rec[$i]['mwst_befreiung'] = " ";
|
|
|
398 |
$rec[$i]['ustid_nr'] = " ";
|
|
|
399 |
$rec[$i]['bestellung'] = " ";
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
$GLOBALS["ui"]->assign( "rec", $rec );
|
|
|
403 |
////////////////////////////////////////////////
|
|
|
404 |
|
|
|
405 |
// Datev-Export Recht
|
|
|
406 |
$GLOBALS["ui"]->assign( "datev_web_recht", $web_rechte['Warenwirtschaft']['rechnungsbuch']['datev_export'] );
|
|
|
407 |
$GLOBALS["ui"]->assign( "datev_user_recht", $user_rechte['Warenwirtschaft']['rechnungsbuch']['datev_export'] );
|
|
|
408 |
/////////////////////
|
|
|
409 |
|
|
|
410 |
// Datev CSV-Export
|
|
|
411 |
if ( empty( $_POST['zeitraum'] ) )
|
|
|
412 |
{
|
|
|
413 |
$_POST['zeitraum'] = 0;
|
|
|
414 |
}
|
|
|
415 |
|
|
|
416 |
$aktMonatJahr = date( "Y-m-d H:i:s", strtotime( "-" . $_POST['zeitraum'] .
|
|
|
417 |
" months" ) );
|
|
|
418 |
$aktMonatJahr = urlencode( $aktMonatJahr );
|
|
|
419 |
$GLOBALS["ui"]->assign( "aktMonatJahr", $aktMonatJahr );
|
|
|
420 |
////////////////////
|
|
|
421 |
|
|
|
422 |
// Templateausgabe
|
|
|
423 |
$GLOBALS["ui"]->display( "rechnungsbuch/rechnungsbuch.tpl" );
|
|
|
424 |
//////////////////
|
|
|
425 |
|
|
|
426 |
|
|
|
427 |
function getRechnungHistory($row) {
|
|
|
428 |
$str = "";
|
|
|
429 |
if($row['1_mahnung_nr']!="0000-00-00 00:00:00") {
|
|
|
430 |
$date = datetime2human( $row['1_mahnung_nr'] );
|
|
|
431 |
$str .= "1. Mahnung am ". $date['Datum']." ".$date['Zeit'] ."<br />";
|
|
|
432 |
}
|
|
|
433 |
if($row['2_mahnung_nr']!="0000-00-00 00:00:00") {
|
|
|
434 |
$date = datetime2human( $row['2_mahnung_nr'] );
|
|
|
435 |
$str .= "2. Mahnung am ". $date['Datum']." ".$date['Zeit'] ."<br />";
|
|
|
436 |
}
|
|
|
437 |
if($row['3_mahnung_nr']!="0000-00-00 00:00:00") {
|
|
|
438 |
$date = datetime2human( $row['3_mahnung_nr'] );
|
|
|
439 |
$str .= "3. Mahnung am ". $date['Datum']." ".$date['Zeit'] ."<br />";
|
|
|
440 |
}
|
|
|
441 |
if($row['bezahlt_am']=="0000-00-00 00:00:00") {
|
|
|
442 |
$str .= "Rechnung noch nicht bezahlt!<br />";
|
|
|
443 |
} else {
|
|
|
444 |
$date = datetime2human( $row['bezahlt_am'] );
|
|
|
445 |
$str .= "Rechnung bezahlt am ". $date['Datum']." ".$date['Zeit'] ."<br />";
|
|
|
446 |
}
|
|
|
447 |
if($row['storniert'] == 1) {
|
|
|
448 |
$str = "storniert";
|
|
|
449 |
}
|
|
|
450 |
return $str;
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
|
455 |
function save_bezahlstatus($status) {
|
|
|
456 |
if(is_array($status)) {
|
|
|
457 |
foreach($status as $rid => $newStatus) {
|
|
|
458 |
switch($newStatus) {
|
|
|
459 |
case "bezahlt":
|
|
|
460 |
$sql = "update
|
|
|
461 |
rechnung
|
|
|
462 |
set
|
|
|
463 |
bezahlt_am = NOW(),
|
|
|
464 |
storniert = 0
|
|
|
465 |
where
|
|
|
466 |
rechnungsnummer = '".$rid."'
|
|
|
467 |
";
|
|
|
468 |
break;
|
|
|
469 |
|
|
|
470 |
case "storniert":
|
|
|
471 |
$sql = "update
|
|
|
472 |
rechnung
|
|
|
473 |
set
|
|
|
474 |
storniert = 1
|
|
|
475 |
where
|
|
|
476 |
rechnungsnummer = '".$rid."'
|
|
|
477 |
";
|
|
|
478 |
break;
|
|
|
479 |
|
|
|
480 |
default:
|
|
|
481 |
}
|
|
|
482 |
if($sql) {
|
|
|
483 |
if($q=mysql_query($sql)){
|
|
|
484 |
|
|
|
485 |
}
|
|
|
486 |
}
|
|
|
487 |
}
|
|
|
488 |
}
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
|
|
|
512 |
?>
|