Beim Test der Oberflaeche im Browser gefunden:
- addrechnung.tpl fragte die gespeicherte Anrede als $rechnung.anr1 ab
(die Daten heissen anrede1) und gab sie ohne Klammern aus. Beim
Bearbeiten von Angeboten/Briefen erschien deshalb immer die
Standard-Anrede, eine geaenderte ging beim erneuten Speichern verloren.
- |escape innerhalb von {if}-Bedingungen wieder entfernt (dort ohne
Wirkung, gehoert nicht dorthin).
- UTF-8-BOM aus sechs Dateien entfernt; makepdf.php gab es auf jeder
Rechnungsseite vor dem HTML aus.
- makeImageFromPDF() loeschte bei der Aufraeumrunde auch .gitkeep;
Pfade fuer convert per escapeshellarg().
- constants.php: Instanzname auch unter Windows (getcwd() mit
Backslashes) korrekt; KV_CONFIG_PATH als Config-Pfad fuer lokale Tests.
Im Browser getestet (lokaler PHP-Webserver, migrierte Testdatenbank):
Login mit Sonderzeichen-Passwort, Entwurf automatisch speichern und
laden, Rechnung mit Umlauten/Anfuehrungszeichen/HTML im Artikelnamen und
Komma-Betraegen speichern, Anzeige als PDF (Original und Kopie),
Kundensuche nach Dokumenten mit Umlaut, Artikelnamen escaped, Storno,
Kopie auf andere Adresse, Umschlag, Angebot mit eigener Anrede anlegen und
wieder bearbeiten.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
362 lines
18 KiB
PHP
362 lines
18 KiB
PHP
<?php
|
|
require_once ("./incs/rechnung.php");
|
|
$smarty->assign("heading","Steuerexport");
|
|
$smarty->display("heading.tpl");
|
|
|
|
if($_GET["do"] == "generate"){
|
|
echo "Generating...";
|
|
$month = mysql_escape_string($_POST["month"]);
|
|
|
|
//RECHNUNGEN
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.adressfields AS adressfields, adresserweiterung, rechnung.id AS rech, ort.plz AS plz, adresse.nname2 AS nname2, adresse.vname2 AS vname2, adresse.nname AS nname, adresse.vname AS vname, adresse.firma AS firma, rechnung. rechnr AS rechnr, DATE_FORMAT(rechnung.datetime,'%d.%m.') AS date, rechnung.partner_id as kundennr, buchungsKontos.kto as buchungsKto
|
|
FROM rechnung
|
|
JOIN adresse ON rechnung.adresse_id = adresse.id
|
|
JOIN strasse ON adresse.str_id = strasse.id
|
|
JOIN ort ON ort.id = strasse.ort_id
|
|
JOIN wahrung ON wahrung_id = wahrung.id
|
|
JOIN rechtyp ON rechnung.typ_id = rechtyp.id
|
|
JOIN zahlziel ON zahlziel_id = zahlziel.id
|
|
JOIN mwst ON mwst_id = mwst.id
|
|
JOIN user ON user_id = user.id
|
|
JOIN buchungsKontos ON buchungsKto_id = buchungsKontos.id
|
|
WHERE rechnung.typ_id = 1 AND DATE_FORMAT(rechnung.datetime, '%Y%m') = '".$month."' ORDER BY rechnung.datetime DESC") or error(mysqli_error($dbconn));
|
|
|
|
$tmppdfname = str_replace(array(" ","."),array("_","_"),microtime());
|
|
|
|
|
|
$fhandle = fopen("./temp/pdftemp/$tmppdfname.csv","w");
|
|
fwrite($fhandle,"Umsatz (ohne Soll/Haben-Kz);Soll/Haben-Kennzeichen;WKZ Umsatz;Kurs;Basis-Umsatz;WKZ Basis-Umsatz;Konto;Gegenkonto (ohne BU-Schlüssel);BU-Schlüssel;Belegdatum;Belegfeld 1;Belegfeld 2;Skonto;Buchungstext;Postensperre;Diverse Adressnummer;Geschäftspartnerbank;Sachverhalt;Zinssperre;Beleglink;Beleginfo - Art 1;Beleginfo - Inhalt 1;Beleginfo - Art 2;Beleginfo - Inhalt 2;Beleginfo - Art 3;Beleginfo - Inhalt 3;Beleginfo - Art 4;Beleginfo - Inhalt 4;Beleginfo - Art 5;Beleginfo - Inhalt 5;Beleginfo - Art 6;Beleginfo - Inhalt 6;Beleginfo - Art 7;Beleginfo - Inhalt 7;Beleginfo - Art 8;Beleginfo - Inhalt 8;KOST1 - Kostenstelle;KOST2 - Kostenstelle;Kost-Menge;EU-Land u. UStID;EU-Steuersatz;Abw. Versteuerungsart;Sachverhalt L+L;Funktionsergänzung L+L;BU 49 Hauptfunktionstyp;BU 49 Hauptfunktionsnummer;BU 49 Funktionsergänzung;Zusatzinformation - Art 1;Zusatzinformation- Inhalt 1;Zusatzinformation - Art 2;Zusatzinformation- Inhalt 2;Zusatzinformation - Art 3;Zusatzinformation- Inhalt 3;Zusatzinformation - Art 4;Zusatzinformation- Inhalt 4;Zusatzinformation - Art 5;Zusatzinformation- Inhalt 5;Zusatzinformation - Art 6;Zusatzinformation- Inhalt 6;Zusatzinformation - Art 7;Zusatzinformation- Inhalt 7;Zusatzinformation - Art 8;Zusatzinformation- Inhalt 8;Zusatzinformation - Art 9;Zusatzinformation- Inhalt 9;Zusatzinformation - Art 10;Zusatzinformation- Inhalt 10;Zusatzinformation - Art 11;Zusatzinformation- Inhalt 11;Zusatzinformation - Art 12;Zusatzinformation- Inhalt 12;Zusatzinformation - Art 13;Zusatzinformation- Inhalt 13;Zusatzinformation - Art 14;Zusatzinformation- Inhalt 14;Zusatzinformation - Art 15;Zusatzinformation- Inhalt 15;Zusatzinformation - Art 16;Zusatzinformation- Inhalt 16;Zusatzinformation - Art 17;Zusatzinformation- Inhalt 17;Zusatzinformation - Art 18;Zusatzinformation- Inhalt 18;Zusatzinformation - Art 19;Zusatzinformation- Inhalt 19;Zusatzinformation - Art 20;Zusatzinformation- Inhalt 20;Stück;Gewicht;Zahlweise;Forderungsart;Veranlagungsjahr;Zugeordnete Fälligkeit;Skontotyp;Auftragsnummer;Buchungstyp;Ust-Schlüssel (Anzahlungen);EU-Land (Anzahlungen);Sachverhalt L+L (Anzahlungen);EU-Steuersatz (Anzahlungen);Erlöskonto (Anzahlungen);Herkunft-Kz;Buchungs GUID;KOST-Datum;Mandatsreferenz\r\n");
|
|
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$adressfields= $res["adressfields"];
|
|
if($adresse["sks"])
|
|
$adressfields = "011111111100";
|
|
$firmaanr = substr($adressfields,ADRFIELD_FIRMAANR,1);
|
|
$firma = substr($adressfields,ADRFIELD_FIRMA,1);
|
|
$anr1 = substr($adressfields,ADRFIELD_ANR1,1);
|
|
$titel1 = substr($adressfields,ADRFIELD_TITEL1,1);
|
|
$name1 = substr($adressfields,ADRFIELD_NAME1,1);
|
|
$anr2 = substr($adressfields,ADRFIELD_ANR2,1);
|
|
$titel2 = substr($adressfields,ADRFIELD_TITEL2,1);
|
|
$name2 = substr($adressfields,ADRFIELD_NAME2,1);
|
|
$str = substr($adressfields,ADRFIELD_STR,1);
|
|
$ort = substr($adressfields,ADRFIELD_ORT,1);
|
|
$land = substr($adressfields,ADRFIELD_LAND,1);
|
|
$zusatz = substr($adressfields,ADRFIELD_ZUSATZ,1);
|
|
$qry2 = mysqli_query($dbconn,"SELECT artikel.bezeichn as bezeichn, preis, wanr, posnr, pagebreak, rabatt, rabatttyp, artikeltyp.bezeichn AS typ, typ_id, menge, angtyp, artikel.id as id
|
|
FROM artikel
|
|
JOIN artikeltyp ON typ_id = artikeltyp.id
|
|
JOIN artikel_rechn ON artikel.id = art_id
|
|
WHERE rech_id = ".$res["rech"]." AND artikel.bezeichn NOT LIKE '%Arbeitswert%' AND artikel.bezeichn NOT LIKE '%Wegewert%' AND artikel.bezeichn NOT LIKE '%Fahrt%' AND artikel.bezeichn NOT LIKE '%Kfz-%' ORDER BY preis DESC LIMIT 1") or error(mysqli_error($dbconn));
|
|
if(mysqli_num_rows($qry2) < 1){
|
|
$res2["bezeichn"] = "Reparatur";
|
|
}
|
|
else{
|
|
$res2 = mysqli_fetch_assoc($qry2);
|
|
if(trim($res2["bezeichn"]) == "")
|
|
$res2["bezeichn"] = "Reparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"ladengurt") or strstr(strtolower($res2["bezeichn"]),"dämmfeder"))
|
|
$res2["bezeichn"] = "Rolladenreparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"textband"))
|
|
$res2["bezeichn"] = "Jalousienreparatur";
|
|
}
|
|
$res["drechnr"] = substr($res["rechnr"],0,4)."-".substr($res["rechnr"],4,2)."-".substr($res["rechnr"],6,2).substr($res["rechnr"],8,2);
|
|
$res["drechnr"] = $res["drechnr"];
|
|
$sumincl = calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
$adrstr = trim($res["adresserweiterung"]);
|
|
if($firma && trim($res["firma"]))
|
|
{
|
|
$adrstr .= trim($res["firma"]);
|
|
}
|
|
elseif( $name1 && !$name2)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
elseif( $name2 && !$name1)
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
else
|
|
{
|
|
if($name1)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
if(trim($name2))
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
}
|
|
fwrite($fhandle,number_format($sumincl,2,",",".").";H;;;;;".$res["buchungsKto"].";1210;;".$res["date"].";".$res["drechnr"].";;;".$res["kundennr"]." - ".$adrstr.";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RE;;;104040000001\r\n");
|
|
}
|
|
|
|
|
|
//STORNOS
|
|
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.adressfields AS adressfields, adresserweiterung, rechnung.id AS rech, ort.plz AS plz, adresse.nname2 AS nname2, adresse.vname2 AS vname2, adresse.nname AS nname, adresse.vname AS vname, adresse.firma AS firma, rechnung. rechnr AS rechnr, DATE_FORMAT(rechnung.stornodate,'%d.%m.') AS date, rechnung.partner_id as kundennr, buchungsKontos.kto as buchungsKto
|
|
FROM rechnung
|
|
JOIN adresse ON rechnung.adresse_id = adresse.id
|
|
JOIN strasse ON adresse.str_id = strasse.id
|
|
JOIN ort ON ort.id = strasse.ort_id
|
|
JOIN wahrung ON wahrung_id = wahrung.id
|
|
JOIN rechtyp ON rechnung.typ_id = rechtyp.id
|
|
JOIN zahlziel ON zahlziel_id = zahlziel.id
|
|
JOIN mwst ON mwst_id = mwst.id
|
|
JOIN user ON user_id = user.id
|
|
JOIN buchungsKontos ON buchungsKto_id = buchungsKontos.id
|
|
WHERE rechnung.typ_id = 1 AND DATE_FORMAT(rechnung.stornodate, '%Y%m') = '".$month."' AND storno = 1 ORDER BY rechnung.stornodate DESC") or error(mysqli_error($dbconn));
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$adressfields= $res["adressfields"];
|
|
if($adresse["sks"])
|
|
$adressfields = "011111111100";
|
|
$firmaanr = substr($adressfields,ADRFIELD_FIRMAANR,1);
|
|
$firma = substr($adressfields,ADRFIELD_FIRMA,1);
|
|
$anr1 = substr($adressfields,ADRFIELD_ANR1,1);
|
|
$titel1 = substr($adressfields,ADRFIELD_TITEL1,1);
|
|
$name1 = substr($adressfields,ADRFIELD_NAME1,1);
|
|
$anr2 = substr($adressfields,ADRFIELD_ANR2,1);
|
|
$titel2 = substr($adressfields,ADRFIELD_TITEL2,1);
|
|
$name2 = substr($adressfields,ADRFIELD_NAME2,1);
|
|
$str = substr($adressfields,ADRFIELD_STR,1);
|
|
$ort = substr($adressfields,ADRFIELD_ORT,1);
|
|
$land = substr($adressfields,ADRFIELD_LAND,1);
|
|
$zusatz = substr($adressfields,ADRFIELD_ZUSATZ,1);
|
|
$adrstr = trim($res["adresserweiterung"]);
|
|
if($firma && trim($res["firma"]))
|
|
{
|
|
$adrstr .= trim($res["firma"]);
|
|
}
|
|
elseif( $name1 && !$name2)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
elseif( $name2 && !$name1)
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
else
|
|
{
|
|
if($name1)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
if(trim($name2))
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
}
|
|
$qry2 = mysqli_query($dbconn,"SELECT artikel.bezeichn as bezeichn, preis, wanr, posnr, pagebreak, rabatt, rabatttyp, artikeltyp.bezeichn AS typ, typ_id, menge, angtyp, artikel.id as id
|
|
FROM artikel
|
|
JOIN artikeltyp ON typ_id = artikeltyp.id
|
|
JOIN artikel_rechn ON artikel.id = art_id
|
|
WHERE rech_id = ".$res["rech"]." AND artikel.bezeichn NOT LIKE '%Arbeitswert%' AND artikel.bezeichn NOT LIKE '%Wegewert%' AND artikel.bezeichn NOT LIKE '%Fahrt%' AND artikel.bezeichn NOT LIKE '%Kfz-%' ORDER BY preis DESC LIMIT 1") or error(mysqli_error($dbconn));
|
|
|
|
if(mysqli_num_rows($qry2) < 1){
|
|
$res2["bezeichn"] = "Reparatur";
|
|
}
|
|
else{
|
|
$res2 = mysqli_fetch_assoc($qry2);
|
|
if(trim($res2["bezeichn"]) == "")
|
|
$res2["bezeichn"] = "Reparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"ladengurt") or strstr(strtolower($res2["bezeichn"]),"dämmfeder"))
|
|
$res2["bezeichn"] = "Rolladenreparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"textband"))
|
|
$res2["bezeichn"] = "Jalousienreparatur";
|
|
}
|
|
$res["drechnr"] = substr($res["rechnr"],0,4)."-".substr($res["rechnr"],4,2)."-".substr($res["rechnr"],6,2).substr($res["rechnr"],8,2);
|
|
$res["drechnr"] = $res["drechnr"];
|
|
$sumincl = calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
fwrite($fhandle,number_format($sumincl,2,",",".").";H;;;;;1210;".$res["buchungsKto"].";;".$res["date"].";".$res["drechnr"].";;;".$res["kundennr"]." - ".$adrstr.";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RE;;;104040000001\r\n");
|
|
}
|
|
|
|
|
|
//GUTSCHRIFTEN
|
|
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.adressfields AS adressfields, adresserweiterung, rechnung.id AS rech, ort.plz AS plz, adresse.nname2 AS nname2, adresse.vname2 AS vname2, adresse.nname AS nname, adresse.vname AS vname, adresse.firma AS firma, rechnung. rechnr AS rechnr, DATE_FORMAT(rechnung.datetime,'%d.%m.') AS date, rechnung.partner_id as kundennr
|
|
FROM rechnung
|
|
JOIN adresse ON rechnung.adresse_id = adresse.id
|
|
JOIN strasse ON adresse.str_id = strasse.id
|
|
JOIN ort ON ort.id = strasse.ort_id
|
|
JOIN wahrung ON wahrung_id = wahrung.id
|
|
JOIN rechtyp ON rechnung.typ_id = rechtyp.id
|
|
JOIN zahlziel ON zahlziel_id = zahlziel.id
|
|
JOIN mwst ON mwst_id = mwst.id
|
|
JOIN user ON user_id = user.id
|
|
WHERE rechnung.typ_id = 2 AND DATE_FORMAT(rechnung.datetime, '%Y%m') = '".$month."' ORDER BY rechnung.datetime DESC") or error(mysqli_error($dbconn));
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$adressfields= $res["adressfields"];
|
|
if($adresse["sks"])
|
|
$adressfields = "011111111100";
|
|
$firmaanr = substr($adressfields,ADRFIELD_FIRMAANR,1);
|
|
$firma = substr($adressfields,ADRFIELD_FIRMA,1);
|
|
$anr1 = substr($adressfields,ADRFIELD_ANR1,1);
|
|
$titel1 = substr($adressfields,ADRFIELD_TITEL1,1);
|
|
$name1 = substr($adressfields,ADRFIELD_NAME1,1);
|
|
$anr2 = substr($adressfields,ADRFIELD_ANR2,1);
|
|
$titel2 = substr($adressfields,ADRFIELD_TITEL2,1);
|
|
$name2 = substr($adressfields,ADRFIELD_NAME2,1);
|
|
$str = substr($adressfields,ADRFIELD_STR,1);
|
|
$ort = substr($adressfields,ADRFIELD_ORT,1);
|
|
$land = substr($adressfields,ADRFIELD_LAND,1);
|
|
$zusatz = substr($adressfields,ADRFIELD_ZUSATZ,1);
|
|
$adrstr = trim($res["adresserweiterung"]);
|
|
if($firma && trim($res["firma"]))
|
|
{
|
|
$adrstr .= trim($res["firma"]);
|
|
}
|
|
elseif( $name1 && !$name2)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
elseif( $name2 && !$name1)
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
else
|
|
{
|
|
if($name1)
|
|
{
|
|
if($res["vname"])
|
|
$adrstr .= trim($res["vname"])." ".trim($res["nname"]);
|
|
else
|
|
$adrstr .= trim($res["nname"]);
|
|
}
|
|
if(trim($name2))
|
|
{
|
|
if($res["vname2"])
|
|
$adrstr .= trim($res["vname2"])." ".trim($res["nname2"]);
|
|
else
|
|
$adrstr .= trim($res["nname2"]);
|
|
}
|
|
}
|
|
$qry2 = mysqli_query($dbconn,"SELECT artikel.bezeichn as bezeichn, preis, wanr, posnr, pagebreak, rabatt, rabatttyp, artikeltyp.bezeichn AS typ, typ_id, menge, angtyp, artikel.id as id
|
|
FROM artikel
|
|
JOIN artikeltyp ON typ_id = artikeltyp.id
|
|
JOIN artikel_rechn ON artikel.id = art_id
|
|
WHERE rech_id = ".$res["rech"]." AND artikel.bezeichn NOT LIKE '%Arbeitswert%' AND artikel.bezeichn NOT LIKE '%Wegewert%' AND artikel.bezeichn NOT LIKE '%Fahrt%' AND artikel.bezeichn NOT LIKE '%Kfz-%' ORDER BY preis DESC LIMIT 1") or error(mysqli_error($dbconn));
|
|
|
|
if(mysqli_num_rows($qry2) < 1){
|
|
$res2["bezeichn"] = "Reparatur";
|
|
}
|
|
else{
|
|
$res2 = mysqli_fetch_assoc($qry2);
|
|
if(trim($res2["bezeichn"]) == "")
|
|
$res2["bezeichn"] = "Reparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"ladengurt") or strstr(strtolower($res2["bezeichn"]),"dämmfeder"))
|
|
$res2["bezeichn"] = "Rolladenreparatur";
|
|
else if(strstr(strtolower($res2["bezeichn"]),"textband"))
|
|
$res2["bezeichn"] = "Jalousienreparatur";
|
|
}
|
|
$res["drechnr"] = substr($res["rechnr"],0,4)."-".substr($res["rechnr"],4,2)."-".substr($res["rechnr"],6,2).substr($res["rechnr"],8,2);
|
|
$res["drechnr"] = $res["drechnr"];
|
|
$sumincl = calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
fwrite($fhandle,number_format($sumincl,2,",",".").";H;;;;;1210;4400;;".$res["date"].";".$res["drechnr"].";;;".$res["kundennr"]." - ".$adrstr.";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RE;;;104040000001\r\n");
|
|
}
|
|
fclose($fhandle);
|
|
echo "<a class='noloading' href='./temp/pdftemp/$tmppdfname.csv'>Öffnen</a><br />";
|
|
}
|
|
else{
|
|
for ($i=0; $i<12; $i++){
|
|
$monthID[$i] = date("Ym",strtotime("-".$i." month") );
|
|
$monthname[$i] = date("M Y",strtotime("-".$i." month"));
|
|
}
|
|
|
|
$smarty->assign('month_ids', $monthID);
|
|
$smarty->assign('month_names', $monthname);
|
|
$smarty->assign('curr_month_id', $monthID[0]);
|
|
|
|
|
|
$sum = 0;
|
|
$sumincl = 0;
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.id AS rech, ort.plz AS plz FROM rechnung JOIN adresse ON adresse_id = adresse.id JOIN strasse ON adresse.str_id = strasse.id JOIN ort ON ort.id = strasse.ort_id WHERE rechnung.typ_id = 1 AND ort.plz = '87509' AND DATE_FORMAT(rechnung.datetime, '%Y') = '".date("Y",strtotime("-0 year"))."'") or error(mysqli_error($dbconn));
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$sumincl += calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
$sum += calculateRechnungsSum($dbconn, $res["rech"],0);
|
|
|
|
}
|
|
$smarty->assign("ffincl0",$sumincl);
|
|
$smarty->assign("ffexcl0",$sum);
|
|
|
|
$sum = 0;
|
|
$sumincl = 0;
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.id AS rech, ort.plz AS plz FROM rechnung JOIN adresse ON adresse_id = adresse.id JOIN strasse ON adresse.str_id = strasse.id JOIN ort ON ort.id = strasse.ort_id WHERE rechnung.typ_id = 1 AND ort.plz = '87509' AND DATE_FORMAT(rechnung.datetime, '%Y') = '".date("Y",strtotime("-1 year"))."'") or error(mysqli_error($dbconn));
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$sumincl += calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
$sum += calculateRechnungsSum($dbconn, $res["rech"],0);
|
|
|
|
}
|
|
$smarty->assign("ffincl1",$sumincl);
|
|
$smarty->assign("ffexcl1",$sum);
|
|
|
|
$sum = 0;
|
|
$sumincl = 0;
|
|
$qry = mysqli_query($dbconn,"SELECT rechnung.id AS rech, ort.plz AS plz FROM rechnung JOIN adresse ON adresse_id = adresse.id JOIN strasse ON adresse.str_id = strasse.id JOIN ort ON ort.id = strasse.ort_id WHERE rechnung.typ_id = 1 AND ort.plz = '87509' AND DATE_FORMAT(rechnung.datetime, '%Y') = '".date("Y",strtotime("-2 years"))."'") or error(mysqli_error($dbconn));
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$sumincl += calculateRechnungsSum($dbconn, $res["rech"],1);
|
|
$sum += calculateRechnungsSum($dbconn, $res["rech"],0);
|
|
|
|
}
|
|
$smarty->assign("ffincl2",$sumincl);
|
|
$smarty->assign("ffexcl2",$sum);
|
|
|
|
$sum = 0;
|
|
$completesum = 0;
|
|
$partners = array();
|
|
$qry = mysqli_query($dbconn,"SELECT GROUP_CONCAT(rechnung.id SEPARATOR ',') AS rechs, partner_id FROM rechnung RIGHT OUTER JOIN partner ON partner_id = partner.id WHERE rechnung.typ_id = 1 AND DATE_FORMAT(rechnung.datetime, '%Y') = '".date("Y",strtotime("-0 year"))."' GROUP BY partner_id");
|
|
while($res = mysqli_fetch_assoc($qry))
|
|
{
|
|
$rechs = explode(',',$res["rechs"]);
|
|
$sum = 0;
|
|
Foreach($rechs AS $rech)
|
|
{
|
|
$sum += calculateRechnungsSum($dbconn, $rech,1);
|
|
}
|
|
$completesum +=$sum;
|
|
if($sum>0)
|
|
{
|
|
$partners[$res["partner_id"]] = $sum;
|
|
}
|
|
}
|
|
|
|
|
|
$smarty->display("stexp.tpl");
|
|
}
|
|
$_SESSION["camefrom"] ="stexp";
|
|
|
|
?>
|