From 2c7f113d6b24860586016f32f6bfe15f045cc688 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Tue, 13 Jun 2023 18:30:48 +0200 Subject: [PATCH] mahnwesen initial --- upgrade/data/db_schema.json | 107 +++- www/lib/class.erpapi.php | 162 +---- www/lib/dokumente/class.rechnung.php | 36 +- www/pages/content/einstellungen.tpl | 4 +- www/pages/content/mahnwesen_edit.tpl | 142 +++++ www/pages/content/mahnwesen_einstellungen.tpl | 10 + www/pages/content/mahnwesen_list.tpl | 19 +- www/pages/mahnwesen.php | 584 ++++++++++++------ www/pages/rechnung.php | 14 +- www/widgets/_gen/widget.gen.rechnung.php | 11 +- 10 files changed, 710 insertions(+), 379 deletions(-) create mode 100644 www/pages/content/mahnwesen_edit.tpl create mode 100644 www/pages/content/mahnwesen_einstellungen.tpl diff --git a/upgrade/data/db_schema.json b/upgrade/data/db_schema.json index 78c38e75..f8f2481b 100644 --- a/upgrade/data/db_schema.json +++ b/upgrade/data/db_schema.json @@ -28975,7 +28975,7 @@ }, { "name": "bestellvorschlag", - "collation": "utf8mb4_general_ci", + "collation": "utf8mb3_general_ci", "type": "BASE TABLE", "columns": [ { @@ -39026,7 +39026,7 @@ }, { "name": "fibu_buchungen", - "collation": "utf8mb4_general_ci", + "collation": "utf8mb3_general_ci", "type": "BASE TABLE", "columns": [ { @@ -39164,13 +39164,13 @@ }, { "name": "fibu_buchungen_alle", - "collation": "utf8mb4_general_ci", + "collation": "utf8mb3_general_ci", "type": "BASE TABLE", "columns": [ { "Field": "buchungsart", "Type": "varchar(9)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", "Default": null, @@ -39203,7 +39203,7 @@ { "Field": "datum", "Type": "varchar(10)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "YES", "Key": "", "Default": null, @@ -39269,7 +39269,7 @@ { "Field": "edit_module", "Type": "varchar(15)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", "Default": null, @@ -39293,13 +39293,13 @@ }, { "name": "fibu_objekte", - "collation": "utf8mb4_general_ci", + "collation": "utf8mb3_general_ci", "type": "BASE TABLE", "columns": [ { "Field": "datum", "Type": "varchar(10)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "YES", "Key": "", "Default": null, @@ -39310,7 +39310,7 @@ { "Field": "typ", "Type": "varchar(15)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", "Default": null, @@ -39343,7 +39343,7 @@ { "Field": "parent_typ", "Type": "varchar(7)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", "Default": null, @@ -39354,7 +39354,7 @@ { "Field": "parent_id", "Type": "varchar(11)", - "Collation": "utf8mb4_general_ci", + "Collation": "utf8mb3_general_ci", "Null": "NO", "Key": "", "Default": null, @@ -101383,7 +101383,7 @@ }, { "name": "subscription_cycle_job", - "collation": "utf8mb4_general_ci", + "collation": "utf8mb3_general_ci", "type": "BASE TABLE", "columns": [ { @@ -117603,6 +117603,89 @@ "Non_unique": "" } ] + }, + { + "name": "mahnwesen", + "collation": "utf8mb3_general_ci", + "type": "BASE TABLE", + "columns": [ + { + "Field": "id", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "PRI", + "Default": null, + "Extra": "auto_increment", + "Privileges": "select,insert,update,references", + "Comment": "" + }, + { + "Field": "name", + "Type": "varchar(50)", + "Collation": "utf8mb3_general_ci", + "Null": "NO", + "Key": "", + "Default": null, + "Extra": "", + "Privileges": "select,insert,update,references", + "Comment": "" + }, + { + "Field": "tage", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "", + "Default": null, + "Extra": "", + "Privileges": "select,insert,update,references", + "Comment": "" + }, + { + "Field": "gebuehr", + "Type": "decimal(10,2)", + "Collation": null, + "Null": "NO", + "Key": "", + "Default": null, + "Extra": "", + "Privileges": "select,insert,update,references", + "Comment": "" + }, + { + "Field": "mail", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "", + "Default": null, + "Extra": "", + "Privileges": "select,insert,update,references", + "Comment": "" + }, + { + "Field": "druck", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "", + "Default": null, + "Extra": "", + "Privileges": "select,insert,update,references", + "Comment": "" + } + ], + "keys": [ + { + "Key_name": "PRIMARY", + "Index_type": "BTREE", + "columns": [ + "id" + ], + "Non_unique": "" + } + ] } ], "views": [ diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 7fd43400..9a3315e6 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -5426,6 +5426,18 @@ title: 'Abschicken', return $ret; } + /* + * Replace {VARS} with texts given in array + * Input array(key => value) + */ + function ParseVars(array $mapping, $text) { + foreach ($mapping as $key => $value) { + $text = str_replace('{'.strtoupper($key).'}',$value,$text); + } + return $text; + } + + // @refactor Document Komponente function CheckBearbeiter($id,$module) { @@ -14548,156 +14560,6 @@ function get_emails ($str) else return false; } - -// @refactor Mahnwesen Modul -function MahnwesenBody($id,$als,$_datum=null,$sprache='') -{ - if($id > 0) - { - $rechnungarr = $this->app->DB->SelectRow("SELECT r.*,DATE_FORMAT(datum,'%d.%m.%Y') as datum_de,DATE_FORMAT(mahnwesen_datum,'%d.%m.%Y') as mahnwesen_datum_de,r.mahnwesen_datum - FROM rechnung AS r WHERE r.id=$id LIMIT 1"); - } - if(empty($rechnungarr)) - { - return ''; - } - - $adresse = $rechnungarr['adresse']; - if($sprache==''){ - $sprache = $rechnungarr['sprache']; - } - if($sprache==''){ - $sprache = $this->app->DB->Select("SELECT sprache FROM adresse WHERE id='$adresse' LIMIT 1"); - } - // OfferNo, customerId, OfferDate - - $kundennummer = $rechnungarr['kundennummer']; - $projekt = $rechnungarr['projekt']; - $auftrag= $rechnungarr['auftrag']; - $buchhaltung= $rechnungarr['buchhaltung']; - $lieferschein = $rechnungarr['lieferschein']; - $lieferscheinid = $lieferschein; - if($lieferscheinid){ - $lieferschein = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferschein' LIMIT 1"); - }else{ - $lieferschein = ''; - } - $bestellbestaetigung = $rechnungarr['kundennummer']; - $datum = $rechnungarr['datum_de']; - $datum_sql = $rechnungarr['datum']; - $belegnr = $rechnungarr['belegnr']; - $doppel = $rechnungarr['doppel']; - $freitext = $rechnungarr['freitext']; - $ustid = $rechnungarr['ustid']; - $soll = $rechnungarr['soll']; - $ist = $rechnungarr['ist']; - $land = $rechnungarr['land']; - $mahnwesen_datum = $rechnungarr['mahnwesen_datum']; - $mahnwesen_datum_deutsch = $rechnungarr['mahnwesen_datum_de']; - $zahlungsweise = $rechnungarr['zahlungsweise']; - $zahlungsstatus = $rechnungarr['zahlungsstatus']; - $zahlungszieltage = $rechnungarr['zahlungszieltage']; - $zahlungszieltageskonto = $rechnungarr['zahlungszieltageskonto']; - $zahlungszielskonto = $rechnungarr['zahlungszielskonto']; - $waehrung = $rechnungarr['waehrung']; - - $zahlungdatum = $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD(datum, INTERVAL $zahlungszieltage DAY),'%d.%m.%Y') FROM rechnung WHERE id='$id' LIMIT 1"); - - if($_datum!=null) - { - $mahnwesen_datum = $this->app->String->Convert($_datum,'%1.%2.%3','%3-%2-%1'); - $mahnwesen_datum_deutsch = $_datum; - } - - $zahlungsweise = strtolower($zahlungsweise); - - if($als=='zahlungserinnerung') - { - $body = $this->GetGeschaeftsBriefText("MahnwesenZahlungserinnerung",$sprache,$projekt,"rechnung",$id); - $tage = $this->GetKonfiguration('mahnwesen_m1_tage'); - } - else if($als=='mahnung1') - { - $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung1",$sprache,$projekt,"rechnung",$id); - $mahngebuehr = $this->GetKonfiguration('mahnwesen_m1_gebuehr'); - $tage = $this->GetKonfiguration('mahnwesen_m2_tage'); - } - else if($als=='mahnung2') - { - $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung2",$sprache,$projekt,"rechnung",$id); - $tage = $this->GetKonfiguration('mahnwesen_m3_tage'); - $mahngebuehr = $this->GetKonfiguration('mahnwesen_m2_gebuehr'); - } - else if($als=='mahnung3') - { - $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung3",$sprache,$projekt,"rechnung",$id); - $tage = $this->GetKonfiguration('mahnwesen_ik_tage'); - $mahngebuehr = $this->GetKonfiguration('mahnwesen_m3_gebuehr'); - } - else if($als=='inkasso') - { - $body = $this->GetGeschaeftsBriefText("MahnwesenInkasso",$sprache,$projekt,"rechnung",$id); - //$tage = $this->GetKonfiguration("mahnwesen_ik_tage"); - $tage = 3; //eigentlich vorbei - $mahngebuehr = $this->GetKonfiguration('mahnwesen_ik_gebuehr'); - } - else - { - $body = $this->app->erp->Beschriftung("dokument_anschreiben"); - } - - if($tage <=0) $tage = 0; - - $datummahnung= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$mahnwesen_datum', INTERVAL $tage DAY),'%d.%m.%Y')"); - $datumrechnungzahlungsziel= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$datum_sql', INTERVAL $zahlungszieltage DAY),'%d.%m.%Y')"); - - $tage_ze = $zahlungszieltage + $this->GetKonfiguration('mahnwesen_m1_tage'); - $datumzahlungserinnerung= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$datum_sql', INTERVAL $tage_ze DAY),'%d.%m.%Y')"); - - // checkstamp $this->CheckStamp("jhdskKUHsiusakiakuhsd"); // errechnet aus laufzeit und kundenid // wenn es nicht drinnen ist darf es nicht gehen - - if($mahngebuehr=='' || !is_numeric($mahngebuehr)) - $mahngebuehr = 0; - - //$offen= '11,23'; - $body = str_replace('{RECHNUNG}',$belegnr,$body); - $body = str_replace('{BELEGNR}',$belegnr,$body); - $body = str_replace('{DATUMRECHNUNG}',$datum,$body); - $body = str_replace('{TAGE}',$tage,$body); - $body = str_replace('{OFFEN}',$this->formatMoney($soll - $ist,$waehrung),$body); - $body = str_replace('{SOLL}',$this->formatMoney($soll,$waehrung),$body); - $body = str_replace('{SUMME}',$this->formatMoney($soll - $ist + $mahngebuehr,$waehrung),$body); - $body = str_replace('{IST}',$this->formatMoney($ist,$waehrung),$body); - $body = str_replace('{DATUM}',$datummahnung,$body); - $body = str_replace('{MAHNGEBUEHR}',$this->formatMoney($mahngebuehr,$waehrung),$body); - $body = str_replace('{OFFENMITMAHNGEBUEHR}',$this->formatMoney($mahngebuehr + $soll - $ist,$waehrung),$body); - $body = str_replace('{MAHNDATUM}',$mahnwesen_datum_deutsch,$body); - - - // Im Protokoll suchen Datum von Zahlungserinnerung, Mahnung 1, Mahnung 2, Mahnung 3 - - $mahnung1 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$id' - AND grund LIKE 'Mahnung1 versendet%' ORDER by Zeit DESC LIMIT 1"); - - $mahnung2 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$id' - AND grund LIKE 'Mahnung2 versendet%' ORDER by Zeit DESC LIMIT 1"); - - $mahnung3 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$id' - AND grund LIKE 'Mahnung3 versendet%' ORDER by Zeit DESC LIMIT 1"); - - $body = str_replace('{DATUMMAHNUNG1}',$mahnung1,$body); - $body = str_replace('{DATUMMAHNUNG2}',$mahnung2,$body); - $body = str_replace('{DATUMMAHNUNG3}',$mahnung3,$body); - - $body = str_replace('{DATUMZAHLUNGSERINNERUNGFAELLIG}',$datumzahlungserinnerung,$body); - $body = str_replace('{DATUMZAHLUNGSERINNERUNG}',$datumzahlungserinnerung,$body); - $body = str_replace('{DATUMRECHNUNGZAHLUNGSZIEL}',$datumrechnungzahlungsziel,$body); - - $body = $this->ParseUserVars('rechnung',$id,$body); - - return $body; -} - /**@deprecated */ function AufragZuDTA($auftrag,$rechnung="1") { diff --git a/www/lib/dokumente/class.rechnung.php b/www/lib/dokumente/class.rechnung.php index b3b4af8e..c02c6c10 100644 --- a/www/lib/dokumente/class.rechnung.php +++ b/www/lib/dokumente/class.rechnung.php @@ -43,9 +43,9 @@ class RechnungPDF extends BriefpapierCustom { parent::__construct($this->app,$projekt,$styleData); } - public function GetRechnung($id,$als="",$doppeltmp=0, $_datum = null) + public function GetRechnung($id, $titel_abw="",$doppeltmp=0, $_datum = null, $text_abw = '') { - $this->parameter = $als; + if($this->app->erp->Firmendaten("steuerspalteausblenden")=="1") { // pruefe ob es mehr als ein steuersatz gibt // wenn ja dann darf man sie nicht ausblenden @@ -124,10 +124,10 @@ class RechnungPDF extends BriefpapierCustom { $lieferschein = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferscheinid' LIMIT 1"); - if(empty($als) || $als === 'doppel') { + /* if(empty($als) || $als === 'doppel') { $rechnungsnummeranzeigen = false; } - elseif(!empty($belegnr)){ + else*/if(!empty($belegnr)){ $rechnungsnummeranzeigen = true; } $projektabkuerzung = $this->app->DB->Select(sprintf('SELECT abkuerzung FROM projekt WHERE id = %d', $projekt)); @@ -172,7 +172,7 @@ class RechnungPDF extends BriefpapierCustom { $zahlungsweisetext = $this->app->erp->Zahlungsweisetext("rechnung",$id); - if($doppel==1) $als = "doppel"; +// if($doppel==1) $als = "doppel"; if($belegnr=="" || $belegnr=="0") $belegnr = "- ".$this->app->erp->Beschriftung("dokument_entwurf"); else { @@ -181,7 +181,7 @@ class RechnungPDF extends BriefpapierCustom { } $posanzeigen = true; - if($als=="zahlungserinnerung") +/* if($als=="zahlungserinnerung") { $this->doctypeOrig=$this->app->erp->Beschriftung("dokument_zahlungserinnerung")." ".(is_null($_datum)?$mahnwesen_datum:$_datum); if($this->app->erp->GetKonfiguration("mahnwesen_ze_pos") === '0')$posanzeigen = false; @@ -207,14 +207,12 @@ class RechnungPDF extends BriefpapierCustom { if($this->app->erp->GetKonfiguration("mahnwesen_inkasso_pos") === '0')$posanzeigen = false; } else - { + {*/ if($rechnungersatz) $this->doctypeOrig=($this->app->erp->Beschriftung("bezeichnungrechnungersatz")?$this->app->erp->Beschriftung("bezeichnungrechnungersatz"):$this->app->erp->Beschriftung("dokument_rechnung"))." $belegnr"; else $this->doctypeOrig=$this->app->erp->Beschriftung("dokument_rechnung")." $belegnr"; - } - - +// } $this->zusatzfooter = " (RE$belegnr)"; @@ -407,12 +405,12 @@ class RechnungPDF extends BriefpapierCustom { - if($als!="" && $als!="doppel") +/* if($als!="" && $als!="doppel") { $body = $this->app->erp->MahnwesenBody($id,$als,$_datum); $footer =$this->app->erp->ParseUserVars("rechnung",$id, $this->app->erp->Beschriftung("rechnung_footer")); } - else { + else {*/ $body = $this->app->erp->Beschriftung("rechnung_header"); if($bodyzusatz!="") $body=$body."\r\n".$bodyzusatz; $body = $this->app->erp->ParseUserVars("rechnung",$id,$body); @@ -442,6 +440,14 @@ class RechnungPDF extends BriefpapierCustom { $footer = $versandinfo."$freitext"."\r\n".$this->app->erp->ParseUserVars("rechnung",$id,$this->app->erp->Beschriftung("rechnung_footer"). "\r\n$steuer\r\n$zahlungsweisetext").$systemfreitext; } +// } + + if ($titel_abw != '') { + $this->doctypeOrig = $titel_abw; + } + + if ($text_abw != '') { + $body = $text_abw; } $this->setTextDetails(array( @@ -686,10 +692,10 @@ class RechnungPDF extends BriefpapierCustom { $tmp_name = str_replace(' ','',trim($this->recipient['enterprise'])); $tmp_name = str_replace('.','',$tmp_name); - if($als=="" || $als=="doppel") - $this->filename = $datum2."_RE".$belegnr.".pdf"; + if($titel_abw != "") + $this->filename = $datum2."_RE".$belegnr."_INFO.pdf"; else - $this->filename = $datum2."_MA".$belegnr.".pdf"; + $this->filename = $datum2."_RE".$belegnr.".pdf"; $this->setBarcode($belegnr); } diff --git a/www/pages/content/einstellungen.tpl b/www/pages/content/einstellungen.tpl index 66751f4a..99595060 100644 --- a/www/pages/content/einstellungen.tpl +++ b/www/pages/content/einstellungen.tpl @@ -68,13 +68,13 @@
' AS `open`";
+
+ $menu = "| " . " |
' AS `open`, CONCAT('') AS `auswahl`";
- $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS m.id, $dropnbox, m.name, m.rest, m.test, m.id FROM mahnwesen m"." WHERE id=$id");
+ $dropnbox = "'
' AS `open`, CONCAT('') AS `auswahl`";
+ $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS m.id, $dropnbox, m.stufe, m.name, m.tage, m.gebuehr, m.mail, m.druck, m.id FROM mahnwesen m"." WHERE id=$id");
foreach ($result[0] as $key => $value) {
$this->app->Tpl->Set(strtoupper($key), $value);
@@ -413,14 +430,16 @@ class Mahnwesen {
/*
* Add displayed items later
- *
+ *
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
*/
-// $this->SetInput($input);
+ $this->app->Tpl->Set('MAIL', $result[0]['mail']?'checked':'');
+ $this->app->Tpl->Set('DRUCK', $result[0]['druck']?'checked':'');
+
$this->app->Tpl->Parse('PAGE', "mahnwesen_edit.tpl");
}
@@ -429,26 +448,215 @@ class Mahnwesen {
*/
public function GetInput(): array {
$input = array();
- //$input['EMAIL'] = $this->app->Secure->GetPOST('email');
-
$input['name'] = $this->app->Secure->GetPOST('name');
- $input['rest'] = $this->app->Secure->GetPOST('rest');
- $input['test'] = $this->app->Secure->GetPOST('test');
-
-
- return $input;
+ $input['stufe'] = $this->app->Secure->GetPOST('stufe');
+ $input['tage'] = $this->app->Secure->GetPOST('tage');
+ $input['gebuehr'] = $this->app->Secure->GetPOST('gebuehr');
+ $input['mail'] = $this->app->Secure->GetPOST('mail')?'1':'0';
+ $input['druck'] = $this->app->Secure->GetPOST('druck')?'1':'0';
+ return $input;
}
/*
* Set all fields in the page corresponding to $input
*/
function SetInput($input) {
- // $this->app->Tpl->Set('EMAIL', $input['email']);
-
$this->app->Tpl->Set('NAME', $input['name']);
- $this->app->Tpl->Set('REST', $input['rest']);
- $this->app->Tpl->Set('TEST', $input['test']);
-
+ $this->app->Tpl->Set('STUFE', $input['stufe']);
+ $this->app->Tpl->Set('TAGE', $input['tage']);
+ $this->app->Tpl->Set('GEBUEHR', $input['gebuehr']);
+ $this->app->Tpl->Set('MAIL', $input['mail']);
+ $this->app->Tpl->Set('DRUCK', $input['druck']);
+ }
+
+
+ /*
+ * Constuct the Mahnwesen message according to GeschÀftsbriefVorlage
+ * Returns Array (string betreff, string body, boolean mail, boolean druck)
+ */
+ function MahnwesenMessage($rechnung_id) {
+
+ $sql = "SELECT
+ r.*,
+ ".$this->app->erp->FormatDate('datum')." datum,
+ ".$this->app->erp->FormatDate('CURRENT_DATE')." heute,
+ m.name as mahn_name,
+ m.tage as mahn_tage,
+ m.gebuehr as mahn_gebuehr,
+ m.mail as mahn_mail,
+ m.druck as mahn_druck
+ FROM
+ rechnung r
+ INNER JOIN
+ mahnwesen m
+ ON
+ r.mahnwesen = m.id WHERE r.id = ".$rechnung_id." LIMIT 1";
+ $rechnungarr = $this->app->DB->SelectArr($sql)[0];
+
+ if (empty($rechnungarr)) {
+ return;
+ }
+
+ $adresse = $rechnungarr['adresse'];
+ if($sprache==''){
+ $sprache = $rechnungarr['sprache'];
+ }
+ if($sprache==''){
+ $sprache = $this->app->DB->Select("SELECT sprache FROM adresse WHERE id='$adresse' LIMIT 1");
+ }
+
+ $kundennummer = $rechnungarr['kundennummer'];
+ $projekt = $rechnungarr['projekt'];
+ $auftrag= $rechnungarr['auftrag'];
+ $buchhaltung= $rechnungarr['buchhaltung'];
+ $lieferschein = $rechnungarr['lieferschein'];
+ $lieferscheinid = $lieferschein;
+ if($lieferscheinid){
+ $lieferschein = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferschein' LIMIT 1");
+ }else{
+ $lieferschein = '';
+ }
+ $bestellbestaetigung = $rechnungarr['kundennummer'];
+ $datum = $rechnungarr['datum_de'];
+ $datum_sql = $rechnungarr['datum'];
+ $belegnr = $rechnungarr['belegnr'];
+ $doppel = $rechnungarr['doppel'];
+ $freitext = $rechnungarr['freitext'];
+ $ustid = $rechnungarr['ustid'];
+ $soll = $rechnungarr['soll'];
+ $ist = $rechnungarr['ist'];
+ $land = $rechnungarr['land'];
+ $mahnwesen_datum = $rechnungarr['mahnwesen_datum'];
+ $mahnwesen_datum_deutsch = $rechnungarr['mahnwesen_datum_de'];
+ $zahlungsweise = $rechnungarr['zahlungsweise'];
+ $zahlungsstatus = $rechnungarr['zahlungsstatus'];
+ $zahlungszieltage = $rechnungarr['zahlungszieltage'];
+ $zahlungszieltageskonto = $rechnungarr['zahlungszieltageskonto'];
+ $zahlungszielskonto = $rechnungarr['zahlungszielskonto'];
+ $waehrung = $rechnungarr['waehrung'];
+
+ $zahlungdatum = $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD(datum, INTERVAL $zahlungszieltage DAY),'%d.%m.%Y') FROM rechnung WHERE id='$rechnung_id' LIMIT 1");
+
+ if($_datum!=null)
+ {
+ $mahnwesen_datum = $this->app->String->Convert($_datum,'%1.%2.%3','%3-%2-%1');
+ $mahnwesen_datum_deutsch = $_datum;
+ }
+
+ $zahlungsweise = strtolower($zahlungsweise);
+ /*
+ if($als=='zahlungserinnerung')
+ {
+ $body = $this->GetGeschaeftsBriefText("MahnwesenZahlungserinnerung",$sprache,$projekt,"rechnung",$rechnung_id);
+ $tage = $this->GetKonfiguration('mahnwesen_m1_tage');
+ }
+ else if($als=='mahnung1')
+ {
+ $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung1",$sprache,$projekt,"rechnung",$rechnung_id);
+ $mahngebuehr = $this->GetKonfiguration('mahnwesen_m1_gebuehr');
+ $tage = $this->GetKonfiguration('mahnwesen_m2_tage');
+ }
+ else if($als=='mahnung2')
+ {
+ $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung2",$sprache,$projekt,"rechnung",$rechnung_id);
+ $tage = $this->GetKonfiguration('mahnwesen_m3_tage');
+ $mahngebuehr = $this->GetKonfiguration('mahnwesen_m2_gebuehr');
+ }
+ else if($als=='mahnung3')
+ {
+ $body = $this->GetGeschaeftsBriefText("MahnwesenMahnung3",$sprache,$projekt,"rechnung",$rechnung_id);
+ $tage = $this->GetKonfiguration('mahnwesen_ik_tage');
+ $mahngebuehr = $this->GetKonfiguration('mahnwesen_m3_gebuehr');
+ }
+ else if($als=='inkasso')
+ {
+ $body = $this->GetGeschaeftsBriefText("MahnwesenInkasso",$sprache,$projekt,"rechnung",$rechnung_id);
+ //$tage = $this->GetKonfiguration("mahnwesen_ik_tage");
+ $tage = 3; //eigentlich vorbei
+ $mahngebuehr = $this->GetKonfiguration('mahnwesen_ik_gebuehr');
+ }
+ else
+ {
+ $body = $this->app->erp->Beschriftung("dokument_anschreiben");
+ } */
+
+ $betreff = $this->app->erp->GetGeschaeftsBriefBetreff($rechnungarr['mahn_name'],$sprache,$projekt,"rechnung",$rechnung_id);
+ $body = $this->app->erp->GetGeschaeftsBriefText($rechnungarr['mahn_name'],$sprache,$projekt,"rechnung",$rechnung_id);
+
+ if (empty($betreff) || empty($body)) {
+ throw new QueryFailureException("Geschaeftsbrief-Vorlage nicht gefunden: ''".$rechnungarr['mahn_name']."'");
+ }
+
+ $offen = $this->app->erp->GetSaldoDokument($rechnung_id, 'rechnung');
+
+ if($tage <=0) $tage = 0;
+
+/* $datummahnung= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$mahnwesen_datum', INTERVAL $tage DAY),'%d.%m.%Y')");
+ $datumrechnungzahlungsziel= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$datum_sql', INTERVAL $zahlungszieltage DAY),'%d.%m.%Y')");
+
+ $tage_ze = $zahlungszieltage + $this->GetKonfiguration('mahnwesen_m1_tage');
+ $datumzahlungserinnerung= $this->app->DB->Select("SELECT DATE_FORMAT(DATE_ADD('$datum_sql', INTERVAL $tage_ze DAY),'%d.%m.%Y')");*/
+
+ // checkstamp $this->CheckStamp("jhdskKUHsiusakiakuhsd"); // errechnet aus laufzeit und kundenid // wenn es nicht drinnen ist darf es nicht gehen
+/*
+ if($mahngebuehr=='' || !is_numeric($mahngebuehr))
+ $mahngebuehr = 0;
+
+ //$offen= '11,23';
+ $body = str_replace('{RECHNUNG}',$belegnr,$body);
+ $body = str_replace('{BELEGNR}',$belegnr,$body);
+ $body = str_replace('{DATUMRECHNUNG}',$datum,$body);
+ $body = str_replace('{TAGE}',$tage,$body);
+ $body = str_replace('{OFFEN}',$this->app->erp->formatMoney(-$offen['betrag'],$offen['waehrung']),$body);
+ $body = str_replace('{SOLL}',$this->app->erp->formatMoney($soll,$waehrung),$body);
+ $body = str_replace('{SUMME}',$this->app->erp->formatMoney($soll - $ist + $mahngebuehr,$waehrung),$body);
+ $body = str_replace('{IST}',$this->app->erp->formatMoney($ist,$waehrung),$body);
+ $body = str_replace('{DATUM}',$datummahnung,$body);
+ $body = str_replace('{MAHNGEBUEHR}',$this->app->erp->formatMoney($mahngebuehr,$waehrung),$body);
+ $body = str_replace('{OFFENMITMAHNGEBUEHR}',$this->app->erp->formatMoney($mahngebuehr + $soll - $ist,$waehrung),$body);
+ $body = str_replace('{MAHNDATUM}',$mahnwesen_datum_deutsch,$body);
+
+
+ // Im Protokoll suchen Datum von Zahlungserinnerung, Mahnung 1, Mahnung 2, Mahnung 3
+
+ $mahnung1 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$rechnung_id'
+ AND grund LIKE 'Mahnung1 versendet%' ORDER by Zeit DESC LIMIT 1");
+
+ $mahnung2 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$rechnung_id'
+ AND grund LIKE 'Mahnung2 versendet%' ORDER by Zeit DESC LIMIT 1");
+
+ $mahnung3 = $this->app->DB->Select("SELECT DATE_FORMAT(zeit,'%d.%m.%Y') FROM rechnung_protokoll WHERE rechnung='$rechnung_id'
+ AND grund LIKE 'Mahnung3 versendet%' ORDER by Zeit DESC LIMIT 1");
+
+ $body = str_replace('{DATUMMAHNUNG1}',$mahnung1,$body);
+ $body = str_replace('{DATUMMAHNUNG2}',$mahnung2,$body);
+ $body = str_replace('{DATUMMAHNUNG3}',$mahnung3,$body);
+
+ $body = str_replace('{DATUMZAHLUNGSERINNERUNGFAELLIG}',$datumzahlungserinnerung,$body);
+ $body = str_replace('{DATUMZAHLUNGSERINNERUNG}',$datumzahlungserinnerung,$body);
+ $body = str_replace('{DATUMRECHNUNGZAHLUNGSZIEL}',$datumrechnungzahlungsziel,$body);*/
+
+ $mapping = [
+ 'rechnung' => $belegnr,
+ 'belegnr' => $belegnr,
+ 'datum' => $datum_sql,
+ 'offen' => $this->app->erp->EUR(-$offen['betrag'])." ".$offen['waehrung'],
+ 'mahngebuehr' => $this->app->erp->EUR($rechnungarr['mahn_gebuehr']),
+ 'heute' => $rechnungarr['heute']
+ ];
+
+ $betreff = $this->app->erp->ParseVars($mapping,$betreff);
+ $body = $this->app->erp->ParseVars($mapping,$body);
+ $body = $this->app->erp->ParseUserVars('rechnung',$rechnung_id,$body);
+
+ return(array(
+ 'betreff' => $betreff,
+ 'body' => $body,
+ 'mail' => $rechnungarr['mahn_mail'] != 0,
+ 'druck' => $rechnungarr['mahn_druck'] != 0,
+ 'empfaenger' => $rechnungarr['email']
+ ));
+
}
}
diff --git a/www/pages/rechnung.php b/www/pages/rechnung.php
index 9f8415cc..9a753ac5 100644
--- a/www/pages/rechnung.php
+++ b/www/pages/rechnung.php
@@ -644,7 +644,11 @@ class Rechnung extends GenRechnung
if($auftragArr[0]['mahnwesen']=='') {
$auftragArr[0]['mahnwesen']='-';
}
+
$this->app->Tpl->Set('MAHNWESEN',$auftragArr[0]['mahnwesen']);
+
+ $this->app->Tpl->Set('MAHNWESEN','XXX');
+
if($auftragArr[0]['mahnwesen_datum']=='0000-00-00') {
$auftragArr[0]['mahnwesen_datum']='-';
}
@@ -889,7 +893,7 @@ class Rechnung extends GenRechnung
$tmp->Query("SELECT zeit,bearbeiter,grund FROM rechnung_protokoll WHERE rechnung='$id' ORDER by zeit DESC",0,"");
$tmp->DisplayNew('PROTOKOLL',"Protokoll","noAction");
-
+/*
$query = $this->app->DB->SelectArr("SELECT zeit,bearbeiter,grund FROM rechnung_protokoll WHERE rechnung='$id' ORDER by zeit");
if($query)
{
@@ -905,12 +909,12 @@ class Rechnung extends GenRechnung
{
$tmp2 = new EasyTable($this->app);
- $tmp2->Query("SELECT concat('