mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-03-05 22:49:48 +01:00
xml rechnung sendmail add file version
This commit is contained in:
parent
bbe92dce2a
commit
dc53b0462c
@ -15246,7 +15246,7 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rechnungarr = $this->app->DB->SelectRow(
|
$rechnungarr = $this->app->DB->SelectRow(
|
||||||
"SELECT adresse, email, name,belegnr,projekt,sprache,schreibschutz,zuarchivieren
|
"SELECT adresse, email, name,belegnr,projekt,sprache,schreibschutz,zuarchivieren,xmlrechnung
|
||||||
FROM rechnung WHERE id='$id' LIMIT 1"
|
FROM rechnung WHERE id='$id' LIMIT 1"
|
||||||
);
|
);
|
||||||
if(empty($rechnungarr)) {
|
if(empty($rechnungarr)) {
|
||||||
@ -15260,6 +15260,7 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
|
|||||||
$to_name = $rechnungarr['name'];
|
$to_name = $rechnungarr['name'];
|
||||||
$belegnr = $rechnungarr['belegnr'];
|
$belegnr = $rechnungarr['belegnr'];
|
||||||
$projekt = $rechnungarr['projekt'];
|
$projekt = $rechnungarr['projekt'];
|
||||||
|
$xmlrechnung = $rechnungarr['xmlrechnung'];
|
||||||
|
|
||||||
$sprache = $rechnungarr['sprache'];
|
$sprache = $rechnungarr['sprache'];
|
||||||
if($sprache=='' && $adresse > 0) {
|
if($sprache=='' && $adresse > 0) {
|
||||||
@ -15284,21 +15285,27 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
|
|||||||
$betreff = $this->ParseUserVars('rechnung',$id,$betreff); // 19.01.2018 eingefuegt BW
|
$betreff = $this->ParseUserVars('rechnung',$id,$betreff); // 19.01.2018 eingefuegt BW
|
||||||
if($id > 0)
|
if($id > 0)
|
||||||
{
|
{
|
||||||
$this->app->erp->BriefpapierHintergrunddisable = false;
|
|
||||||
if(class_exists('RechnungPDFCustom'))
|
|
||||||
{
|
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
|
||||||
}else{
|
|
||||||
$Brief = new RechnungPDF($this->app,$projekt);
|
|
||||||
}
|
|
||||||
$Brief->GetRechnung($id);
|
|
||||||
$arrtmpfile[] = $Brief->displayTMP();
|
|
||||||
|
|
||||||
if(!$Brief->DocumentArchiviert()) {
|
if (!$xmlrechnung) {
|
||||||
$Brief->ArchiviereDocument(true, true);
|
$this->app->erp->BriefpapierHintergrunddisable = false;
|
||||||
|
if(class_exists('RechnungPDFCustom'))
|
||||||
|
{
|
||||||
|
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
||||||
|
}else{
|
||||||
|
$Brief = new RechnungPDF($this->app,$projekt);
|
||||||
|
}
|
||||||
|
$Brief->GetRechnung($id);
|
||||||
|
$arrtmpfile[] = $Brief->displayTMP();
|
||||||
|
|
||||||
|
if(!$Brief->DocumentArchiviert()) {
|
||||||
|
$Brief->ArchiviereDocument(true, true);
|
||||||
|
}
|
||||||
|
$md5arr[] = @md5_file($arrtmpfile[(!empty($arrtmpfile)?count($arrtmpfile):0)-1]);
|
||||||
|
} else {
|
||||||
|
$arrtmpfile = Array();
|
||||||
|
$md5arr = Array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$md5arr[] = @md5_file($arrtmpfile[(!empty($arrtmpfile)?count($arrtmpfile):0)-1]);
|
|
||||||
// anhaenge automatisch mitversenden
|
// anhaenge automatisch mitversenden
|
||||||
$resultdateien = $this->app->DB->SelectArr("SELECT datei FROM datei_stichwoerter WHERE objekt LIKE 'Rechnung' AND parameter='$id'");
|
$resultdateien = $this->app->DB->SelectArr("SELECT datei FROM datei_stichwoerter WHERE objekt LIKE 'Rechnung' AND parameter='$id'");
|
||||||
$cResultdateien = !empty($resultdateien)?count($resultdateien):0;
|
$cResultdateien = !empty($resultdateien)?count($resultdateien):0;
|
||||||
@ -23489,54 +23496,63 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
|
|||||||
if($typ=="rechnung")
|
if($typ=="rechnung")
|
||||||
{
|
{
|
||||||
// sende
|
// sende
|
||||||
$this->app->erp->BriefpapierHintergrunddisable = !$this->app->erp->BriefpapierHintergrunddisable;
|
$xmlrechnug = $this->app->DB->Select("SELECT xmlrechnung FROM rechnung WHERE id ='".$id."' LIMIT 1");
|
||||||
if(class_exists('RechnungPDFCustom'))
|
if ($xmlrechnung) {
|
||||||
{
|
$xmlrechnungresult = $this->app->erp->GetXMLRechnung($id);
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
if ($xmlrechnungresult['success']) {
|
||||||
}else{
|
$tmpfile = $xmlrechnungresult['xml'];
|
||||||
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
} else {
|
||||||
}
|
throw new exception("XML Rechnung fehlgeschlagen!");
|
||||||
$Brief->GetRechnung($id);
|
}
|
||||||
|
} else {
|
||||||
|
$this->app->erp->BriefpapierHintergrunddisable = !$this->app->erp->BriefpapierHintergrunddisable;
|
||||||
|
if(class_exists('RechnungPDFCustom'))
|
||||||
|
{
|
||||||
|
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
||||||
|
}else{
|
||||||
|
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
||||||
|
}
|
||||||
|
$Brief->GetRechnung($id);
|
||||||
|
|
||||||
if(isset($sammelpdf))
|
if(isset($sammelpdf))
|
||||||
{
|
{
|
||||||
foreach($sammelpdf as $dat)
|
foreach($sammelpdf as $dat)
|
||||||
{
|
{
|
||||||
$Brief->AddPDF($dat);
|
$Brief->AddPDF($dat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$Brief->ArchiviereDocument();
|
//$Brief->ArchiviereDocument();
|
||||||
$tmpfile = $Brief->displayTMP();
|
$tmpfile = $Brief->displayTMP();
|
||||||
$Brief->ArchiviereDocument(true);
|
$Brief->ArchiviereDocument(true);
|
||||||
unlink($tmpfile);
|
unlink($tmpfile);
|
||||||
$this->app->erp->BriefpapierHintergrunddisable = !$this->app->erp->BriefpapierHintergrunddisable;
|
$this->app->erp->BriefpapierHintergrunddisable = !$this->app->erp->BriefpapierHintergrunddisable;
|
||||||
if(class_exists('RechnungPDFCustom'))
|
if(class_exists('RechnungPDFCustom'))
|
||||||
{
|
{
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
||||||
}else{
|
}else{
|
||||||
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
||||||
|
}
|
||||||
|
$Brief->GetRechnung($id);
|
||||||
|
$tmpfile = $Brief->displayTMP();
|
||||||
|
$Brief->ArchiviereDocument(true);
|
||||||
|
if(isset($sammelpdf))
|
||||||
|
{
|
||||||
|
unlink($tmpfile);
|
||||||
|
if(class_exists('RechnungPDFCustom'))
|
||||||
|
{
|
||||||
|
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
||||||
|
}else{
|
||||||
|
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
||||||
|
}
|
||||||
|
$Brief->GetRechnung($id);
|
||||||
|
foreach($sammelpdf as $dat)
|
||||||
|
{
|
||||||
|
$Brief->AddPDF($dat);
|
||||||
|
}
|
||||||
|
$tmpfile = $Brief->displayTMP();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$Brief->GetRechnung($id);
|
|
||||||
$tmpfile = $Brief->displayTMP();
|
|
||||||
$Brief->ArchiviereDocument(true);
|
|
||||||
if(isset($sammelpdf))
|
|
||||||
{
|
|
||||||
unlink($tmpfile);
|
|
||||||
if(class_exists('RechnungPDFCustom'))
|
|
||||||
{
|
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projektbriefpapier);
|
|
||||||
}else{
|
|
||||||
$Brief = new RechnungPDF($this->app,$projektbriefpapier);
|
|
||||||
}
|
|
||||||
$Brief->GetRechnung($id);
|
|
||||||
foreach($sammelpdf as $dat)
|
|
||||||
{
|
|
||||||
$Brief->AddPDF($dat);
|
|
||||||
}
|
|
||||||
$tmpfile = $Brief->displayTMP();
|
|
||||||
}
|
|
||||||
|
|
||||||
//$Brief->ArchiviereDocument();
|
//$Brief->ArchiviereDocument();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -29231,7 +29247,6 @@ function Firmendaten($field,$projekt="")
|
|||||||
|
|
||||||
function SetXMLRechnung($id)
|
function SetXMLRechnung($id)
|
||||||
{
|
{
|
||||||
/** @var Preisanfrage $obj */
|
|
||||||
$obj = $this->app->erp->LoadModul('rechnung');
|
$obj = $this->app->erp->LoadModul('rechnung');
|
||||||
if(!empty($obj) && method_exists($obj,'SetXMLRechnung')) {
|
if(!empty($obj) && method_exists($obj,'SetXMLRechnung')) {
|
||||||
return $obj->SetXMLRechnung($id);
|
return $obj->SetXMLRechnung($id);
|
||||||
@ -29239,6 +29254,15 @@ function Firmendaten($field,$projekt="")
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetXMLRechnung($id)
|
||||||
|
{
|
||||||
|
$obj = $this->app->erp->LoadModul('rechnung');
|
||||||
|
if(!empty($obj) && method_exists($obj,'RechnungSmarty')) {
|
||||||
|
return $obj->RechnungSmarty(id: $id, returnvalue: true);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
function BelegFreigabe($beleg,$id)
|
function BelegFreigabe($beleg,$id)
|
||||||
{
|
{
|
||||||
if($id <= 0 || empty($beleg)) {
|
if($id <= 0 || empty($beleg)) {
|
||||||
@ -33055,7 +33079,6 @@ function Firmendaten($field,$projekt="")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function DeleteBestellung($id)
|
function DeleteBestellung($id)
|
||||||
{
|
{
|
||||||
/** @var Bestellung $obj */
|
/** @var Bestellung $obj */
|
||||||
@ -33066,7 +33089,6 @@ function Firmendaten($field,$projekt="")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function CreateRechnung($adresse="")
|
function CreateRechnung($adresse="")
|
||||||
{
|
{
|
||||||
/** @var Rechnung $obj */
|
/** @var Rechnung $obj */
|
||||||
@ -33076,7 +33098,6 @@ function Firmendaten($field,$projekt="")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function GetStandardWaehrung($projekt=0)
|
public function GetStandardWaehrung($projekt=0)
|
||||||
{
|
{
|
||||||
if(is_array($projekt) && isset($projekt['eigenesteuer']) && isset($projekt['waehrung'])) {
|
if(is_array($projekt) && isset($projekt['eigenesteuer']) && isset($projekt['waehrung'])) {
|
||||||
|
@ -5717,7 +5717,7 @@ Die Gesamtsumme stimmt nicht mehr mit ursprünglich festgelegten Betrag '.
|
|||||||
|
|
||||||
$this->app->erp->ANABREGSNeuberechnen($rechnung,"rechnung");
|
$this->app->erp->ANABREGSNeuberechnen($rechnung,"rechnung");
|
||||||
$this->app->erp->rechnung_zahlstatus_berechnen($id);
|
$this->app->erp->rechnung_zahlstatus_berechnen($id);
|
||||||
$this->app->erp->PDFArchivieren("rechnung",$rechnung);
|
$this->app->erp->RechnungArchivieren($rechnung);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// auftrag_position geliefert_menge und geliefert anpassen
|
// auftrag_position geliefert_menge und geliefert anpassen
|
||||||
@ -6129,15 +6129,12 @@ Die Gesamtsumme stimmt nicht mehr mit ursprünglich festgelegten Betrag '.
|
|||||||
}
|
}
|
||||||
unlink($tmpfile);
|
unlink($tmpfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the invoice as last step
|
// Send the invoice as last step
|
||||||
if($autodruckrechnungstufe1mail && $rechnung > 0)
|
if($autodruckrechnungstufe1mail && $rechnung > 0)
|
||||||
{
|
{
|
||||||
$this->app->erp->Rechnungsmail($rechnung);
|
$this->app->erp->Rechnungsmail($rechnung);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->erp->RunHook('auftrag_versand_ende', 1, $id);
|
$this->app->erp->RunHook('auftrag_versand_ende', 1, $id);
|
||||||
|
|
||||||
// wenn per URL aufgerufen
|
// wenn per URL aufgerufen
|
||||||
if($internmodus!='1')
|
if($internmodus!='1')
|
||||||
{
|
{
|
||||||
|
@ -205,27 +205,52 @@ class Rechnung extends GenRechnung
|
|||||||
function RechnungArchiviereXML($id = null) {
|
function RechnungArchiviereXML($id = null) {
|
||||||
if ($id === null) {
|
if ($id === null) {
|
||||||
$id = (int)$this->app->Secure->GetGET('id');
|
$id = (int)$this->app->Secure->GetGET('id');
|
||||||
|
$redirect = true;
|
||||||
}
|
}
|
||||||
$result = $this->RechnungSmarty(id: $id, json: false, returnvalue: true);
|
$result = $this->RechnungSmarty(id: $id, json: false, returnvalue: true);
|
||||||
|
|
||||||
if ($result['success']) {
|
if ($result['success']) {
|
||||||
$this->app->erp->CreateDateiWithStichwort(
|
|
||||||
name: $result['filename'].'.xml',
|
// Check for old files
|
||||||
titel: $result['title'],
|
$existing = false;
|
||||||
beschreibung: '',
|
$existing_ids = $this->app->erp->GetDateiSubjektObjekt('rechnung','rechnung',$id);
|
||||||
nummer: '',
|
foreach ($existing_ids as $existing_id) {
|
||||||
datei: $result['xml'],
|
if($this->app->erp->GetDateiEndung($existing_id) == 'xml') {
|
||||||
ersteller: $this->app->User->GetName(),
|
$existing = true;
|
||||||
subjekt: 'rechnung',
|
break;
|
||||||
objekt: 'rechnung',
|
}
|
||||||
parameter: $id
|
}
|
||||||
);
|
|
||||||
|
if ($existing) {
|
||||||
|
$this->app->erp->AddDateiVersion(
|
||||||
|
id: $existing_id,
|
||||||
|
ersteller: $this->app->User->GetName(),
|
||||||
|
dateiname: $result['filename'].'.xml',
|
||||||
|
bemerkung: '',
|
||||||
|
datei: $result['xml'],
|
||||||
|
path: ""
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->app->erp->CreateDateiWithStichwort(
|
||||||
|
name: $result['filename'].'.xml',
|
||||||
|
titel: $result['title'],
|
||||||
|
beschreibung: '',
|
||||||
|
nummer: '',
|
||||||
|
datei: $result['xml'],
|
||||||
|
ersteller: $this->app->User->GetName(),
|
||||||
|
subjekt: 'rechnung',
|
||||||
|
objekt: 'rechnung',
|
||||||
|
parameter: $id
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new exception("XML Rechnung fehlgeschlagen!");
|
throw new exception("XML Rechnung fehlgeschlagen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->DB->Update("UPDATE rechnung SET schreibschutz='1', zuarchivieren = '0' WHERE id='$id'");
|
$this->app->DB->Update("UPDATE rechnung SET schreibschutz='1', zuarchivieren = '0' WHERE id='$id'");
|
||||||
$this->app->Location->execute('index.php?module=rechnung&action=edit&id='.$id);
|
if ($redirect) {
|
||||||
|
$this->app->Location->execute('index.php?module=rechnung&action=edit&id='.$id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function RechnungArchivierePDF()
|
function RechnungArchivierePDF()
|
||||||
@ -1300,7 +1325,7 @@ class Rechnung extends GenRechnung
|
|||||||
$result['rechnungssteller']['ort'] = $this->app->erp->Firmendaten('ort');
|
$result['rechnungssteller']['ort'] = $this->app->erp->Firmendaten('ort');
|
||||||
$result['rechnungssteller']['plz'] = $this->app->erp->Firmendaten('plz');
|
$result['rechnungssteller']['plz'] = $this->app->erp->Firmendaten('plz');
|
||||||
$result['rechnungssteller']['land'] = $this->app->erp->Firmendaten('land');
|
$result['rechnungssteller']['land'] = $this->app->erp->Firmendaten('land');
|
||||||
$result['rechnungssteller']['steuernummer'] = $this->app->erp->Firmendaten('steuernummer');
|
$result['rechnungssteller']['steuernummer'] = $this->app->erp->Firmendaten('steuernummer');
|
||||||
|
|
||||||
$rechnung = $this->app->DB->SelectRow("
|
$rechnung = $this->app->DB->SelectRow("
|
||||||
SELECT * FROM rechnung WHERE id = $id LIMIT 1
|
SELECT * FROM rechnung WHERE id = $id LIMIT 1
|
||||||
@ -1321,13 +1346,13 @@ class Rechnung extends GenRechnung
|
|||||||
throw new exception("Rechnung enthält keine Positionen!");
|
throw new exception("Rechnung enthält keine Positionen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$steuern = Array();
|
$steuern = Array();
|
||||||
foreach ($positionen as $key => $position) {
|
foreach ($positionen as $key => $position) {
|
||||||
$this->app->erp->GetSteuerPosition('rechnung', $position['id'], $steuersatz, $steuertext, $erloes);
|
$this->app->erp->GetSteuerPosition('rechnung', $position['id'], $steuersatz, $steuertext, $erloes);
|
||||||
$positionen[$key]['steuersatz'] = $steuersatz;
|
$positionen[$key]['steuersatz'] = $steuersatz;
|
||||||
$positionen[$key]['steuertext'] = $steuertext;
|
$positionen[$key]['steuertext'] = $steuertext;
|
||||||
$positionen[$key]['erloese'] = $erloes;
|
$positionen[$key]['erloese'] = $erloes;
|
||||||
|
|
||||||
$steuern[$steuersatz]['umsatz_netto'] += $position['umsatz_netto_gesamt'];
|
$steuern[$steuersatz]['umsatz_netto'] += $position['umsatz_netto_gesamt'];
|
||||||
$steuern[$steuersatz]['umsatz_brutto'] += $position['umsatz_brutto_gesamt'];
|
$steuern[$steuersatz]['umsatz_brutto'] += $position['umsatz_brutto_gesamt'];
|
||||||
$steuern[$steuersatz]['prozent'] = $steuersatz;
|
$steuern[$steuersatz]['prozent'] = $steuersatz;
|
||||||
@ -1341,15 +1366,15 @@ class Rechnung extends GenRechnung
|
|||||||
$this->remove_html_entities_from_array($result);
|
$this->remove_html_entities_from_array($result);
|
||||||
$this->remove_CDATA_fragments_from_array($result);
|
$this->remove_CDATA_fragments_from_array($result);
|
||||||
|
|
||||||
if ($json) {
|
if ($json) {
|
||||||
$headers[] = 'Content-type:text/plain';
|
$headers[] = 'Content-type:text/plain';
|
||||||
$headers[] = 'Content-Disposition: attachment;filename='.$filename.'.json';
|
$headers[] = 'Content-Disposition: attachment;filename='.$filename.'.json';
|
||||||
$output = json_encode($result,JSON_PRETTY_PRINT);
|
$output = json_encode($result,JSON_PRETTY_PRINT);
|
||||||
} else {
|
} else {
|
||||||
$headers[] = 'Content-type:text/xml';
|
$headers[] = 'Content-type:text/xml';
|
||||||
$headers[] = 'Content-Disposition: attachment;filename='.$filename.'.xml';
|
$headers[] = 'Content-Disposition: attachment;filename='.$filename.'.xml';
|
||||||
$template_id = $this->GetXMLSmartyTemplate($id);
|
$template_id = $this->GetXMLSmartyTemplate($id);
|
||||||
if(empty($template_id)) {
|
if(empty($template_id)) {
|
||||||
$output = '<?xml version="1.0" encoding="utf-8"?>
|
$output = '<?xml version="1.0" encoding="utf-8"?>
|
||||||
<note>
|
<note>
|
||||||
<body>Kein Smarty Template an der Addresse hinterlegt!</body>
|
<body>Kein Smarty Template an der Addresse hinterlegt!</body>
|
||||||
@ -1357,12 +1382,12 @@ class Rechnung extends GenRechnung
|
|||||||
$success = false;
|
$success = false;
|
||||||
} else {
|
} else {
|
||||||
$template = $this->app->DB->Select("SELECT template from smarty_templates WHERE id = '$template_id' LIMIT 1");
|
$template = $this->app->DB->Select("SELECT template from smarty_templates WHERE id = '$template_id' LIMIT 1");
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
$directory = $this->app->erp->GetTMP().'/smarty/templates';
|
$directory = $this->app->erp->GetTMP().'/smarty/templates';
|
||||||
$smarty->setCompileDir($directory);
|
$smarty->setCompileDir($directory);
|
||||||
$smarty->assign('rechnung', $output);
|
$smarty->assign('rechnung', $output);
|
||||||
$output = $smarty->fetch('string:'.$template);
|
$output = $smarty->fetch('string:'.$template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($returnvalue) {
|
if ($returnvalue) {
|
||||||
@ -1482,7 +1507,7 @@ class Rechnung extends GenRechnung
|
|||||||
public function CopyRechnungPosition()
|
public function CopyRechnungPosition()
|
||||||
{
|
{
|
||||||
$this->app->YUI->SortListEvent('copy','rechnung_position','rechnung');
|
$this->app->YUI->SortListEvent('copy','rechnung_position','rechnung');
|
||||||
$this->RechnungPositionen();
|
$this->RechnungPositionen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DelRechnungPosition()
|
public function DelRechnungPosition()
|
||||||
@ -1768,7 +1793,7 @@ class Rechnung extends GenRechnung
|
|||||||
$punkte = $rechnungarr['punkte'];//$this->app->DB->Select("SELECT punkte FROM rechnung WHERE id='$id' LIMIT 1");
|
$punkte = $rechnungarr['punkte'];//$this->app->DB->Select("SELECT punkte FROM rechnung WHERE id='$id' LIMIT 1");
|
||||||
$bonuspunkte = $rechnungarr['bonuspunkte'];//$this->app->DB->Select("SELECT bonuspunkte FROM rechnung WHERE id='$id' LIMIT 1");
|
$bonuspunkte = $rechnungarr['bonuspunkte'];//$this->app->DB->Select("SELECT bonuspunkte FROM rechnung WHERE id='$id' LIMIT 1");
|
||||||
$soll = $rechnungarr['soll'];//$this->app->DB->Select("SELECT soll FROM rechnung WHERE id='$id' LIMIT 1");
|
$soll = $rechnungarr['soll'];//$this->app->DB->Select("SELECT soll FROM rechnung WHERE id='$id' LIMIT 1");
|
||||||
$projekt = $rechnungarr['projekt'];
|
$projekt = $rechnungarr['projekt'];
|
||||||
$skontosoll = $this->app->DB->Select("SELECT TRUNCATE(soll*(1-(zahlungszielskonto/100)),2) as skontosoll FROM rechnung where id = '".$id."' LIMIT 1");
|
$skontosoll = $this->app->DB->Select("SELECT TRUNCATE(soll*(1-(zahlungszielskonto/100)),2) as skontosoll FROM rechnung where id = '".$id."' LIMIT 1");
|
||||||
$xmlrechnung = $rechnungarr['xmlrechnung'];
|
$xmlrechnung = $rechnungarr['xmlrechnung'];
|
||||||
$zahlungsweise= $rechnungarr['zahlungsweise'];
|
$zahlungsweise= $rechnungarr['zahlungsweise'];
|
||||||
@ -1817,7 +1842,7 @@ class Rechnung extends GenRechnung
|
|||||||
|
|
||||||
if($nummer!='') {
|
if($nummer!='') {
|
||||||
|
|
||||||
$this->app->Tpl->Set('NUMMER',$nummer);
|
$this->app->Tpl->Set('NUMMER',$nummer);
|
||||||
|
|
||||||
if (($schreibschutz!='1') && $this->app->erp->RechteVorhanden('rechnung','belegnredit')){
|
if (($schreibschutz!='1') && $this->app->erp->RechteVorhanden('rechnung','belegnredit')){
|
||||||
$this->app->Tpl->Set('BELEGNRHIDDEN','hidden');
|
$this->app->Tpl->Set('BELEGNRHIDDEN','hidden');
|
||||||
@ -1926,7 +1951,7 @@ class Rechnung extends GenRechnung
|
|||||||
|
|
||||||
$this->app->erp->RemoveReadonly('ist');
|
$this->app->erp->RemoveReadonly('ist');
|
||||||
|
|
||||||
if($this->app->erp->Firmendaten('mahnwesenmitkontoabgleich')!='1' || $this->app->DB->Select("SELECT mahnwesenfestsetzen FROM rechnung WHERE id='$id' LIMIT 1")==1)
|
if($this->app->erp->Firmendaten('mahnwesenmitkontoabgleich')!='1' || $this->app->DB->Select("SELECT mahnwesenfestsetzen FROM rechnung WHERE id='$id' LIMIT 1")==1)
|
||||||
$this->app->erp->RemoveReadonly('ist');*/
|
$this->app->erp->RemoveReadonly('ist');*/
|
||||||
|
|
||||||
//$auftrag= $this->app->DB->Select("SELECT auftrag FROM rechnung WHERE id='$id' LIMIT 1");
|
//$auftrag= $this->app->DB->Select("SELECT auftrag FROM rechnung WHERE id='$id' LIMIT 1");
|
||||||
@ -2009,7 +2034,7 @@ class Rechnung extends GenRechnung
|
|||||||
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
$saldo = $this->app->erp->GetSaldoDokument($id,'rechnung');
|
$saldo = $this->app->erp->GetSaldoDokument($id,'rechnung');
|
||||||
if (empty($saldo)) {
|
if (empty($saldo)) {
|
||||||
$this->app->Tpl->Set('SCHNELLEINGABE_HIDDEN', 'hidden');
|
$this->app->Tpl->Set('SCHNELLEINGABE_HIDDEN', 'hidden');
|
||||||
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
||||||
@ -2025,7 +2050,7 @@ class Rechnung extends GenRechnung
|
|||||||
|
|
||||||
if (!empty($rechnung_schnelleingabe_konto)) {
|
if (!empty($rechnung_schnelleingabe_konto)) {
|
||||||
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
$this->app->Tpl->Set('SCHNELLEINGABE_TOOLTIP_HIDDEN', 'hidden');
|
||||||
if ($speichern!='' && $this->app->erp->RechteVorhanden('rechnung','manuellbezahltmarkiert') && !empty($zahlbetrag)) {
|
if ($speichern!='' && $this->app->erp->RechteVorhanden('rechnung','manuellbezahltmarkiert') && !empty($zahlbetrag)) {
|
||||||
if ($bezahlt_am == '0000-00-00') {
|
if ($bezahlt_am == '0000-00-00') {
|
||||||
$bezahlt_am = date('Y-m-d');
|
$bezahlt_am = date('Y-m-d');
|
||||||
}
|
}
|
||||||
@ -2054,7 +2079,7 @@ class Rechnung extends GenRechnung
|
|||||||
$this->app->DB->Insert($sql);
|
$this->app->DB->Insert($sql);
|
||||||
$kontoauszug = $this->app->DB->GetInsertID();
|
$kontoauszug = $this->app->DB->GetInsertID();
|
||||||
$this->app->erp->fibu_buchungen_buchen("kontoauszuege",$kontoauszug, "rechnung", $id, -$zahlbetrag, 'EUR', $bezahlt_am, "Rechnung ".$nummer." Schnelleingabe");
|
$this->app->erp->fibu_buchungen_buchen("kontoauszuege",$kontoauszug, "rechnung", $id, -$zahlbetrag, 'EUR', $bezahlt_am, "Rechnung ".$nummer." Schnelleingabe");
|
||||||
$this->rechnung_zahlstatus_berechnen($id);
|
$this->rechnung_zahlstatus_berechnen($id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->app->Tpl->Set('SCHNELLEINGABE_HIDDEN', 'hidden');
|
$this->app->Tpl->Set('SCHNELLEINGABE_HIDDEN', 'hidden');
|
||||||
@ -2271,24 +2296,13 @@ class Rechnung extends GenRechnung
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->app->erp->RechnungArchivieren($invoiceId);
|
$this->app->erp->RechnungArchivieren($invoiceId);
|
||||||
if(class_exists('RechnungPDFCustom')) {
|
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$Brief = new RechnungPDF($this->app,$projekt);
|
|
||||||
}
|
|
||||||
$Brief->GetRechnung($invoiceId);
|
|
||||||
$tmpfile = $Brief->displayTMP();
|
|
||||||
$Brief->ArchiviereDocument();
|
|
||||||
@unlink($tmpfile);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RechnungList()
|
public function RechnungList()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
|
||||||
|
|
||||||
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
||||||
{
|
{
|
||||||
@ -2322,6 +2336,7 @@ class Rechnung extends GenRechnung
|
|||||||
implode(', ', $auswahl)
|
implode(', ', $auswahl)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($auswahl as $v) {
|
foreach($auswahl as $v) {
|
||||||
if(!$v) {
|
if(!$v) {
|
||||||
continue;
|
continue;
|
||||||
@ -2441,7 +2456,7 @@ class Rechnung extends GenRechnung
|
|||||||
if ($xmlrechnung) {
|
if ($xmlrechnung) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$projekt = $this->app->DB->Select("SELECT projekt FROM rechnung WHERE id=$v LIMIT 1");
|
$projekt = $this->app->DB->Select("SELECT projekt FROM rechnung WHERE id=$v LIMIT 1");
|
||||||
if(class_exists('RechnungPDFCustom')) {
|
if(class_exists('RechnungPDFCustom')) {
|
||||||
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
||||||
}
|
}
|
||||||
@ -2643,7 +2658,7 @@ class Rechnung extends GenRechnung
|
|||||||
$zahlungszieltageskonto = 0;
|
$zahlungszieltageskonto = 0;
|
||||||
$zahlungszielskonto = 0;
|
$zahlungszielskonto = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->DB->Insert("INSERT INTO rechnung (
|
$this->app->DB->Insert("INSERT INTO rechnung (
|
||||||
id,
|
id,
|
||||||
datum,
|
datum,
|
||||||
@ -2662,8 +2677,7 @@ class Rechnung extends GenRechnung
|
|||||||
ohne_briefpapier,
|
ohne_briefpapier,
|
||||||
angelegtam,
|
angelegtam,
|
||||||
usereditid,
|
usereditid,
|
||||||
abweichendebezeichnung,
|
abweichendebezeichnung
|
||||||
xmlrechnung
|
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
'',
|
'',
|
||||||
@ -2683,8 +2697,7 @@ class Rechnung extends GenRechnung
|
|||||||
'".$ohnebriefpapier."',
|
'".$ohnebriefpapier."',
|
||||||
NOW(),
|
NOW(),
|
||||||
'$usereditid',
|
'$usereditid',
|
||||||
'$abweichendebezeichnung',
|
'$abweichendebezeichnung'
|
||||||
'$xmlrechnung'
|
|
||||||
)"
|
)"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2701,8 +2714,8 @@ class Rechnung extends GenRechnung
|
|||||||
$deliverythresholdvatid = $this->app->DB->real_escape_string($deliverythresholdvatid);
|
$deliverythresholdvatid = $this->app->DB->real_escape_string($deliverythresholdvatid);
|
||||||
$this->app->DB->Update("UPDATE rechnung SET deliverythresholdvatid = '$deliverythresholdvatid' WHERE id = $id LIMIT 1");
|
$this->app->DB->Update("UPDATE rechnung SET deliverythresholdvatid = '$deliverythresholdvatid' WHERE id = $id LIMIT 1");
|
||||||
}
|
}
|
||||||
|
$this->SetXMLRechnung($id);
|
||||||
$this->app->erp->SchnellFreigabe('rechnung',$id);
|
$this->app->erp->SchnellFreigabe('rechnung',$id);
|
||||||
|
|
||||||
$this->app->erp->LoadSteuersaetzeWaehrung($id,'rechnung',$projekt);
|
$this->app->erp->LoadSteuersaetzeWaehrung($id,'rechnung',$projekt);
|
||||||
$this->app->erp->EventAPIAdd('EventRechnungCreate',$id,'rechnung','create');
|
$this->app->erp->EventAPIAdd('EventRechnungCreate',$id,'rechnung','create');
|
||||||
|
|
||||||
@ -3013,7 +3026,7 @@ class Rechnung extends GenRechnung
|
|||||||
foreach ($zahlungen as $zahlung) {
|
foreach ($zahlungen as $zahlung) {
|
||||||
$row = array(
|
$row = array(
|
||||||
$zahlung['datum'],
|
$zahlung['datum'],
|
||||||
"<a href=\"index.php?module=".$zahlung['doc_typ']."&action=edit&id=".$zahlung['doc_id']."\">
|
"<a href=\"index.php?module=".$zahlung['doc_typ']."&action=edit&id=".$zahlung['doc_id']."\">
|
||||||
".ucfirst($zahlung['doc_typ'])."
|
".ucfirst($zahlung['doc_typ'])."
|
||||||
".$zahlung['doc_info']."
|
".$zahlung['doc_info']."
|
||||||
</a>",
|
</a>",
|
||||||
@ -3024,7 +3037,7 @@ class Rechnung extends GenRechnung
|
|||||||
}
|
}
|
||||||
|
|
||||||
$salden = $this->app->erp->GetSaldenDokument($id,'rechnung');
|
$salden = $this->app->erp->GetSaldenDokument($id,'rechnung');
|
||||||
foreach ($salden as $saldo) {
|
foreach ($salden as $saldo) {
|
||||||
$row = array(
|
$row = array(
|
||||||
'',
|
'',
|
||||||
'<b>Saldo</b>',
|
'<b>Saldo</b>',
|
||||||
@ -3033,7 +3046,7 @@ class Rechnung extends GenRechnung
|
|||||||
);
|
);
|
||||||
$et->AddRow($row);
|
$et->AddRow($row);
|
||||||
}
|
}
|
||||||
return($et->DisplayNew('return',""));
|
return($et->DisplayNew('return',""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3055,8 +3068,8 @@ class Rechnung extends GenRechnung
|
|||||||
waehrung,
|
waehrung,
|
||||||
datum,
|
datum,
|
||||||
zahlungszieltage,
|
zahlungszieltage,
|
||||||
DATE_ADD(datum, INTERVAL zahlungszieltage DAY) as zieldatum,
|
DATE_ADD(datum, INTERVAL zahlungszieltage DAY) as zieldatum,
|
||||||
CURRENT_DATE > DATE_ADD(datum, INTERVAL zahlungszieltage DAY) as faellig,
|
CURRENT_DATE > DATE_ADD(datum, INTERVAL zahlungszieltage DAY) as faellig,
|
||||||
zahlungszielskonto,
|
zahlungszielskonto,
|
||||||
TRUNCATE(soll*(1-(zahlungszielskonto/100)),2) as skontosoll,
|
TRUNCATE(soll*(1-(zahlungszielskonto/100)),2) as skontosoll,
|
||||||
zahlungszieltageskonto,
|
zahlungszieltageskonto,
|
||||||
@ -3071,7 +3084,7 @@ class Rechnung extends GenRechnung
|
|||||||
$saldo = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung');
|
$saldo = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung');
|
||||||
if (!empty($saldo)) {
|
if (!empty($saldo)) {
|
||||||
if ($saldo['waehrung'] == $offene_rechnung['waehrung']) {
|
if ($saldo['waehrung'] == $offene_rechnung['waehrung']) {
|
||||||
$offene_rechnung['ist'] = $offene_rechnung['soll']+$saldo['betrag'];
|
$offene_rechnung['ist'] = $offene_rechnung['soll']+$saldo['betrag'];
|
||||||
// Check for skonto
|
// Check for skonto
|
||||||
$skontorelevante_zahlungen = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung','zubuchung',$offene_rechnung['zieldatumskonto'])['betrag'];
|
$skontorelevante_zahlungen = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung','zubuchung',$offene_rechnung['zieldatumskonto'])['betrag'];
|
||||||
$zielkonforme_zahlungen = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung','zubuchung',$offene_rechnung['zieldatum'])['betrag'];
|
$zielkonforme_zahlungen = $this->app->erp->GetSaldoDokument($offene_rechnung['id'],'rechnung','zubuchung',$offene_rechnung['zieldatum'])['betrag'];
|
||||||
@ -3081,7 +3094,7 @@ class Rechnung extends GenRechnung
|
|||||||
} else if (abs($skontorelevante_zahlungen-$offene_rechnung['skontosoll']) <= 0.01) {
|
} else if (abs($skontorelevante_zahlungen-$offene_rechnung['skontosoll']) <= 0.01) {
|
||||||
// Skonto ok -> book difference
|
// Skonto ok -> book difference
|
||||||
$sachkonto = $this->app->erp->Firmendaten('rechnung_skonto_kontorahmen');
|
$sachkonto = $this->app->erp->Firmendaten('rechnung_skonto_kontorahmen');
|
||||||
if (!empty($sachkonto)) {
|
if (!empty($sachkonto)) {
|
||||||
$this->app->erp->fibu_buchungen_buchen('rechnung',$offene_rechnung['id'],'kontorahmen',$sachkonto,$offene_rechnung['soll']-$skontorelevante_zahlungen,$offene_rechnung['waehrung'],date('Y-m-d'),'');
|
$this->app->erp->fibu_buchungen_buchen('rechnung',$offene_rechnung['id'],'kontorahmen',$sachkonto,$offene_rechnung['soll']-$skontorelevante_zahlungen,$offene_rechnung['waehrung'],date('Y-m-d'),'');
|
||||||
$offene_rechnung['ist'] = $offene_rechnung['soll'];
|
$offene_rechnung['ist'] = $offene_rechnung['soll'];
|
||||||
$saldo['betrag'] = 0;
|
$saldo['betrag'] = 0;
|
||||||
@ -3098,16 +3111,16 @@ class Rechnung extends GenRechnung
|
|||||||
SET
|
SET
|
||||||
ist = ".$saldo['betrag']."+soll,
|
ist = ".$saldo['betrag']."+soll,
|
||||||
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
|
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
|
||||||
WHERE id=".$offene_rechnung['id'];
|
WHERE id=".$offene_rechnung['id'];
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$offene_rechnung['id']);
|
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$offene_rechnung['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->app->erp->fibu_rebuild_tables();
|
$this->app->erp->fibu_rebuild_tables();
|
||||||
// END RECALCULATE
|
// END RECALCULATE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user