Compare commits

...

7 Commits

8 changed files with 441 additions and 79 deletions

View File

@ -117352,7 +117352,7 @@
{
"name": "fibu_objekte_view",
"type": "VIEW",
"Create": "CREATE VIEW `fibu_objekte_view` AS select `fo`.`datum` AS `datum`,`fo`.`typ` AS `typ`,`fo`.`id` AS `id`,`fo`.`info` AS `info` from (select `auftrag`.`datum` AS `datum`,'auftrag' AS `typ`,`auftrag`.`id` AS `id`,`auftrag`.`belegnr` AS `info` from `auftrag` where `auftrag`.`belegnr` <> '' union select `rechnung`.`datum` AS `datum`,'rechnung' AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`belegnr` AS `info` from `rechnung` where `rechnung`.`belegnr` <> '' union select `gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`belegnr` AS `belegnr` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select `verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`rechnung` AS `belegnr` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select `kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,concat(`konten`.`kurzbezeichnung`,' - ',`kontoauszuege`.`buchungstext`) AS `buchungstext` from (`kontoauszuege` left join `konten` on(`konten`.`id` = `kontoauszuege`.`konto`)) union select '' AS `datum`,'kontorahmen' AS `'kontorahmen'`,`kontorahmen`.`id` AS `id`,`kontorahmen`.`beschriftung` AS `beschriftung` from `kontorahmen`) `fo` where `fo`.`datum` >= (select `firmendaten_werte`.`wert` from `firmendaten_werte` where `firmendaten_werte`.`name` = 'fibu_buchungen_startdatum') or `fo`.`datum` = ''"
"Create": "CREATE VIEW `fibu_objekte_view` AS select `fo`.`datum` AS `datum`,`fo`.`typ` AS `typ`,`fo`.`id` AS `id`,`fo`.`info` AS `info`,`fo`.`typ` in ('rechnung','gutschrift','verbindlichkeit','auftrag') AS `is_beleg` from (select `auftrag`.`datum` AS `datum`,'auftrag' AS `typ`,`auftrag`.`id` AS `id`,`auftrag`.`belegnr` AS `info` from `auftrag` where `auftrag`.`belegnr` <> '' union select `rechnung`.`datum` AS `datum`,'rechnung' AS `typ`,`rechnung`.`id` AS `id`,`rechnung`.`belegnr` AS `info` from `rechnung` where `rechnung`.`belegnr` <> '' union select `gutschrift`.`datum` AS `datum`,'gutschrift' AS `gutschrift`,`gutschrift`.`id` AS `id`,`gutschrift`.`belegnr` AS `belegnr` from `gutschrift` where `gutschrift`.`belegnr` <> '' union select `verbindlichkeit`.`rechnungsdatum` AS `rechnungsdatum`,'verbindlichkeit' AS `verbindlichkeit`,`verbindlichkeit`.`id` AS `id`,`verbindlichkeit`.`rechnung` AS `belegnr` from `verbindlichkeit` where `verbindlichkeit`.`belegnr` <> '' union select `kontoauszuege`.`buchung` AS `buchung`,'kontoauszuege' AS `kontoauszuege`,`kontoauszuege`.`id` AS `id`,concat(`konten`.`kurzbezeichnung`,' - ',`kontoauszuege`.`buchungstext`) AS `buchungstext` from (`kontoauszuege` left join `konten` on(`konten`.`id` = `kontoauszuege`.`konto`)) union select '' AS `datum`,'kontorahmen' AS `'kontorahmen'`,`kontorahmen`.`id` AS `id`,concat(`kontorahmen`.`sachkonto`,' - ',`kontorahmen`.`beschriftung`) AS `beschriftung` from `kontorahmen`) `fo` where `fo`.`datum` >= (select `firmendaten_werte`.`wert` from `firmendaten_werte` where `firmendaten_werte`.`name` = 'fibu_buchungen_startdatum') or `fo`.`datum` = ''"
},
{
"name": "fibu_buchungen_alle_view",

View File

@ -33,7 +33,7 @@
[TAB1NEXT]
</div>
<div id="tabs-2">
<form action="" enctype="multipart/form-data" method="POST">
<form action="#tabs-2" enctype="multipart/form-data" method="POST">
[MESSAGE]
<div class="row">
<div class="row-height">

View File

@ -4,32 +4,63 @@
</ul>
<div id="tabs-1">
[MESSAGE]
<form action="" method="post">
[FORMHANDLEREVENT]
<div class="row">
<div class="row-height">
<div class="col-xs-12 col-md-10 col-md-height">
<div class="col-xs-12 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|Offene Einzelsalden|}</legend>
<div class="filter-box filter-usersave">
<div class="filter-block filter-inline">
<div class="filter-title">{|Filter|}</div>
<ul class="filter-list">
<li class="filter-item">
<label for="vorschlagfilter" class="switch">
<input type="checkbox" id="vorschlagfilter">
<span class="slider round"></span>
</label>
<label for="vorschlagfilter">{|Vorschl&auml;ge|}</label>
</li>
<li class="filter-item">
<label for="checkedfilter" class="switch">
<input type="checkbox" id="checkedfilter">
<span class="slider round"></span>
</label>
<label for="checkedfilter">{|Betrag korrekt|}</label>
</li>
</ul>
</div>
</div>
<form action="" method="post" id="buchungenform">
[TAB1]
</form>
</fieldset>
</div>
</div>
<div class="col-xs-12 col-md-2 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<table width="100%" border="0" class="mkTableFormular">
<legend>{|Aktionen|}</legend>
<table>
<legend>Stapelverarbeitung</legend>
<tr>
<td><input type="checkbox" value="1" id="autoalle" />&nbsp;alle markieren&nbsp;</td>
</tr>
<form action="" method="post">
<td><button name="submit" value="neuberechnen" class="ui-button-icon" style="width:100%;">{|Buchungen neu berechnen|}</button></td></tr>
<td><button name="submit" value="BUCHEN" class="ui-button-icon" style="width:100%;">{|BUCHEN|}</button></td></tr>
</form>
<td><button name="submit" form = "buchungenform" value="BUCHEN" class="ui-button-icon" style="width:100%;">{|Markierte BUCHEN|}</button></td></tr>
</table>
</fieldset>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<script>
$('#autoalle').on('change',function(){
var wert = $(this).prop('checked');
$('#fibu_buchungen_zuordnen').find('input[type="checkbox"]').prop('checked',wert);
$('#fibu_buchungen_zuordnen').find('input[type="checkbox"]').first().trigger('change');
});
</script>

View File

@ -19,7 +19,8 @@ class Fibu_buchungen {
$this->app->ActionHandler("edit", "fibu_buchungen_edit");
$this->app->ActionHandler("delete", "fibu_buchungen_delete");
$this->app->ActionHandler("assoc", "fibu_buchungen_assoc");
$this->app->ActionHandler("zuordnen", "fibu_buchungen_zuordnen");
//$this->app->ActionHandler("zuordnen", "fibu_buchungen_zuordnen");
$this->app->ActionHandler("zuordnen", "fibu_buchungen_zuordnen_tablesearch");
$this->app->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app);
@ -178,6 +179,227 @@ class Fibu_buchungen {
$count = "SELECT count(DISTINCT id) FROM fibu_buchungen_alle WHERE $where";
// $groupby = "";
break;
case 'fibu_buchungen_zuordnen':
$allowed['fibu_buchungen_zuordnung'] = array('list');
$heading = array('','','Datum', 'Info', 'Betrag', 'W&auml;hrung', 'Buchungsbetrag','Vorschlag', 'Men&uuml;');
$width = array( );
$findcols = array('','auswahl','datum','objektlink','saldo','waehrung','buchwert_input','vorschlag');
$searchsql = array();
$defaultorder = 1;
$defaultorderdesc = 0;
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=fibu_buchungen&action=einzelzuordnen&doc=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/forward.svg\" border=\"0\"></a></td></tr></table>";
$linkstart = '<table cellpadding=0 cellspacing=0><tr><td nowrap><a href="index.php?module=fibu_buchungen&action=edit&';
$linkend = '"><img src="./themes/'.$app->Conf->WFconf['defaulttheme'].'/images/forward.svg" border=0></a></td></tr></table>';
$typ = $this->app->User->GetParameter('fibu_buchungen_doc_typ');
$objektlink = array (
'<a href=\"index.php?action=edit&module=',
['sql' => 'fb.typ'],
'&id=',
['sql' => 'fb.id'],
'">',
['sql' => 'fo.info'],
'</a>'
);
$check_sql = "(fo.info <> '' AND salden.saldonum = -SUM(fbd.betrag))";
$auswahl = array (
'<input type=\"text\" name=\"ids[]\" value=\"',
['sql' => 'salden.typ'],
'_',
['sql' => 'salden.id'],
'" hidden/>',
'<input type=\"checkbox\" name=\"auswahl[]\" value="',
['sql' => 'salden.typ'],
'_',
['sql' => 'salden.id'],
'"',
['sql' => "if(".$check_sql.",'checked','')"],
' />'
);
$vorschlaege = array (
'<a href=\"index.php?action=edit&module=',
['sql' => 'COALESCE(fo.typ,\'\')'],
'&id=',
['sql' => 'COALESCE(fo.id,\'\')'],
'\">',
['sql' => $this->app->erp->FormatUCfirst('COALESCE(fo.typ,\'\')')],
' ',
['sql' => 'COALESCE(fo.info,\'\')'],
' ',
['sql' => "if (SUM(fbd.betrag) IS NULL,'',CONCAT('(Saldo ',".$this->app->erp->FormatMenge('SUM(fbd.betrag)',2).",')'))"],
'</a> ',
'<input type="text" name="vorschlaege[]" value="',
['sql' => 'COALESCE(fo.typ,\'\')'],
'_',
['sql' => 'COALESCE(fo.id,\'\')'],
'" hidden/>'
);
$werte = array (
'<input type="number" step="0.01" name="werte[]" value="',
['sql' => 'salden.saldonum'],
'" min="',
['sql' => 'if(salden.saldonum < 0,salden.saldonum,0)'],
'" max="',
['sql' => 'if(salden.saldonum < 0,0,salden.saldonum)'],
'"/>'
);
$waehrungen = array (
['sql' => 'salden.waehrung'],
'<input type="text" name="waehrungen[]" value="',
['sql' => 'salden.waehrung'],
'" hidden/>'
);
$doc = array (
['sql' => 'salden.typ'],
'_',
['sql' => 'salden.id'],
);
$sql = "SELECT
'' AS dummy,
'' AS dummy2,
auswahl,
datum,
objektlink,
saldo,
waehrung,
wert,
vorschlag,
doc,
doc_id,
doc_saldo,
checked
FROM
(
SELECT
'' AS dummy,
".$this->app->erp->ConcatSQL($auswahl)." AS auswahl,
salden.datum,
salden.typ,
salden.id,
salden.info,
salden.saldo,
salden.objektlink,
salden.saldonum,
".$this->app->erp->ConcatSQL($vorschlaege)." AS vorschlag,
".$this->app->erp->ConcatSQL($werte)." AS wert,
".$this->app->erp->ConcatSQL($waehrungen)." AS waehrung,
fo.typ AS doc_typ,
fo.id AS doc_id,
fo.info AS doc_info,
SUM(fbd.betrag) as doc_saldo,
if(".$check_sql.",'1','0') AS checked,
".$this->app->erp->ConcatSQL($doc)." AS doc
FROM
(
SELECT
".$this->app->erp->FormatDate(" fb.datum ")." AS datum,
fb.typ,
fb.id,
fo.info,
".$this->app->erp->ConcatSQL($objektlink)." AS objektlink,
".$this->app->erp->FormatMenge('SUM(COALESCE(fb.betrag,0))',2)." AS saldo,
SUM(betrag) AS saldonum,
fb.waehrung
FROM
`fibu_buchungen_alle` fb
INNER JOIN fibu_objekte fo ON
fb.typ = fo.typ AND fb.id = fo.id
WHERE
(
fb.typ = '".$typ."' OR '".$typ."' = ''
)
GROUP BY
fb.typ,
fb.id,
fb.waehrung
) salden
LEFT JOIN(
SELECT
fo.typ,
fo.id,
fo.info
FROM
fibu_objekte fo
WHERE fo.is_beleg = 1
GROUP BY
fo.typ,
fo.id,
fo.info
) AS fo
ON
salden.info LIKE CONCAT('%', fo.info, '%') AND salden.typ <> fo.typ AND fo.info <> ''
LEFT JOIN
fibu_buchungen_alle fbd
ON
fbd.typ = fo.typ AND fbd.id = fo.id
WHERE
salden.saldonum <> 0
GROUP BY
salden.typ,
salden.id
) AS erg
";
$where = "1";
// Toggle filters
$this->app->Tpl->Add('JQUERYREADY', "$('#vorschlagfilter').click( function() { fnFilterColumn1( 0 ); } );");
$this->app->Tpl->Add('JQUERYREADY', "$('#checkedfilter').click( function() { fnFilterColumn2( 0 ); } );");
for ($r = 1;$r <= 4;$r++) {
$this->app->Tpl->Add('JAVASCRIPT', '
function fnFilterColumn' . $r . ' ( i )
{
if(oMoreData' . $r . $name . '==1)
oMoreData' . $r . $name . ' = 0;
else
oMoreData' . $r . $name . ' = 1;
$(\'#' . $name . '\').dataTable().fnFilter(
\'\',
i,
0,0
);
}
');
}
$more_data1 = $this->app->Secure->GetGET("more_data1");
if ($more_data1 == 1) {
$where .= " AND doc_id IS NOT NULL";
} else {
}
$more_data2 = $this->app->Secure->GetGET("more_data2");
if ($more_data2 == 1) {
$where .= " AND checked = 1";
} else {
}
// END Toggle filters
// $count = "SELECT count(DISTINCT id) FROM fibu_buchungen_alle WHERE $where";
$groupby = "GROUP BY typ, id";
//echo($sql." WHERE ".$where." ".$groupby);
break;
}
@ -214,6 +436,7 @@ class Fibu_buchungen {
$submit = $this->app->Secure->GetPOST('submit');
if ($submit == 'neuberechnen') {
$this->fibu_rebuild_tables();
$msg = "<div class=\"info\">Buchungen wurden neu berechnet.</div>";
}
// For transfer to tablesearch
@ -226,6 +449,10 @@ class Fibu_buchungen {
$this->app->YUI->TableSearch('TAB1', 'fibu_buchungen_salden', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->YUI->TableSearch('TAB2', 'fibu_buchungen_list', "show", "", "", basename(__FILE__), __CLASS__);
if (!empty($msg)) {
$this->app->Tpl->Set('MESSAGE', $msg);
}
$this->app->Tpl->Parse('PAGE', "fibu_buchungen_list.tpl");
}
@ -233,7 +460,7 @@ class Fibu_buchungen {
$id = (int) $this->app->Secure->GetGET('id');
// $this->app->DB->Delete("DELETE FROM `fibu_buchungen` WHERE `id` = '{$id}'");
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gel&ouml;scht.</div>");
// $this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gel&ouml;scht.</div>");
$this->fibu_buchungen_list();
}
@ -429,6 +656,72 @@ class Fibu_buchungen {
}
function fibu_buchungen_zuordnen_tablesearch() {
$this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=list", "&Uuml;bersicht");
// $this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=create", "Neu anlegen");
$submit = $this->app->Secure->GetPOST('submit');
if ($submit == 'neuberechnen') {
$this->fibu_rebuild_tables();
$msg = "<div class=\"info\">Buchungen wurden neu berechnet.</div>";
}
if ($submit == 'BUCHEN') {
// Process multi action
$ids = $this->app->Secure->GetPOST('ids');
$werte = $this->app->Secure->GetPOST('werte');
$waehrungen = $this->app->Secure->GetPOST('waehrungen');
$auswahl = $this->app->Secure->GetPOST('auswahl');
$vorschlaege = $this->app->Secure->GetPOST('vorschlaege');
if (!empty($auswahl)) {
foreach ($ids as $id) {
$key_ids = array_search($id,$ids);
$key_auswahl = array_search($id,$auswahl);
if ($key_auswahl !== false && $vorschlaege[$key_ids] != '_') {
$von = explode('_',$id);
$von_typ = strtolower($von[0]);
$von_id = (int) $von[1];
$doc = $vorschlaege[$key_ids];
$doc = explode('_',$doc);
$doc_typ = strtolower($doc[0]);
$doc_id = (int) $doc[1];
$betrag = $werte[$key_ids];
$waehrung = $waehrungen[$key_ids];
$sql = "INSERT INTO `fibu_buchungen` (`von_typ`, `von_id`, `nach_typ`, `nach_id`, `betrag`, `waehrung`, `benutzer`, `zeit`, `internebemerkung`) VALUES ('".$von_typ."','".$von_id."','".$doc_typ."', '".$doc_id."', '".-$betrag."', '".$waehrung."', '".$this->app->User->GetID()."','". $input['zeit'] = date("Y-m-d H:i")."', '')";
$this->app->DB->Insert($sql);
}
}
}
}
$this->fibu_rebuild_tables();
// For transfer to tablesearch
$doc_typ = $this->app->Secure->GetGET('typ');
$this->app->User->SetParameter('fibu_buchungen_doc_typ', $doc_typ);
// $this->app->YUI->TableSearch('TAB1', 'fibu_buchungen_salden', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->YUI->TableSearch('TAB1', 'fibu_buchungen_zuordnen', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->YUI->TableSearch('TAB2', 'fibu_buchungen_list', "show", "", "", basename(__FILE__), __CLASS__);
if (!empty($msg)) {
$this->app->Tpl->Set('MESSAGE', $msg);
}
$this->app->Tpl->Parse('PAGE', "fibu_buchungen_zuordnen.tpl");
}
function fibu_buchungen_zuordnen() {
$this->app->erp->MenuEintrag("index.php?module=fibu_buchungen&action=list", "&Uuml;bersicht");
@ -518,7 +811,9 @@ class Fibu_buchungen {
fb.waehrung
) salden
LEFT JOIN fibu_objekte fo ON
salden.info LIKE CONCAT('%', fo.info, '%') AND salden.typ <> fo.typ AND fo.info <> ''
salden.info LIKE CONCAT('%', fo.info, '%')
AND
salden.typ <> fo.typ AND fo.info <> ''
WHERE
salden.saldonum <> 0
GROUP BY

View File

@ -1399,23 +1399,6 @@ class Gutschrift extends GenGutschrift
$this->app->DB->Update("UPDATE gutschrift SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
// First refresh all open items
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from gutschrift WHERE zahlungsstatus != 'bezahlt'");
foreach ($openids as $openid) {
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'gutschrift');
if (!empty($saldo)) {
if ($saldo['waehrung'] == $openid['waehrung']) {
$sql = "UPDATE gutschrift SET ist = soll-'".$saldo['betrag']."' WHERE id=".$openid['id'];
$result = $this->app->DB->Update($sql);
}
}
else {
$this->app->DB->Update("UPDATE gutschrift SET ist = null WHERE id=".$openid['id']);
}
}
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('gutschrift', 'edit')) {
$drucker = $this->app->Secure->GetPOST('seldrucker');
$aktion = $this->app->Secure->GetPOST('sel_aktion');
@ -1659,6 +1642,28 @@ class Gutschrift extends GenGutschrift
}
}
// refresh all open items
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from gutschrift WHERE zahlungsstatus != 'bezahlt'");
foreach ($openids as $openid) {
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'gutschrift');
if (!empty($saldo)) {
if ($saldo['waehrung'] == $openid['waehrung']) {
$sql = "UPDATE
gutschrift
SET
ist = ".$saldo['betrag']."+soll,
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
WHERE id=".$openid['id'];
$this->app->DB->Update($sql);
}
}
else {
$this->app->DB->Update("UPDATE gutschrift SET ist = null WHERE id=".$openid['id']);
}
}
$backurl = $this->app->Secure->GetGET('backurl');
$backurl = $this->app->erp->base64_url_decode($backurl);

View File

@ -1030,7 +1030,7 @@ class Importvorlage extends GenImportvorlage {
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $stueckliste_csv)) {
//$importfilename = $_FILES['userfile']['name'];
$msg = $this->app->erp->base64_url_encode("<div class=\"error\">Die Datei konnte nicht ge&ouml;ffnet werden. Eventuell ist die Datei zu gro&szlig; oder die Schreibrechte stimmen nicht!</div> ");
$msg = $this->app->erp->base64_url_encode("<div class=\"error\">Die Datei '".$stueckliste_csv."' konnte nicht ge&ouml;ffnet werden. Eventuell ist die Datei zu gro&szlig; oder die Schreibrechte stimmen nicht!</div> ");
$this->app->Location->execute("index.php?module=importvorlage&action=import&id=$id&msg=$msg");
}
@ -5145,7 +5145,7 @@ class Importvorlage extends GenImportvorlage {
$row['konto'] = $kontoid[0]['id'];
$row['importdatum'] = date("Y-m-d H:i:s");
$sql = "SELECT pruefsumme FROM kontoauszuege WHERE pruefsumme='".$row['pruefsumme']."' AND konto ='".$row['konto']."'";
$sql = "SELECT pruefsumme FROM kontoauszuege WHERE pruefsumme='".$row['pruefsumme']."' AND konto ='".$row['konto']."' AND importfehler IS NULL";
$result = $this->app->DB->SelectArr($sql);
if (!empty($result)) {

View File

@ -265,6 +265,20 @@ class Kontoauszuege {
$this->app->Tpl->Parse('PAGE', "kontoauszuege_konto_list.tpl");
}
function kontoauszuege_mark_as_error(int $id) : ?string {
$sql = "SELECT id FROM fibu_buchungen_alle WHERE CONCAT(doc_typ,doc_id) <> CONCAT('kontoauszuege','".$id."') AND typ = 'kontoauszuege' AND id = ".$id;
$result = $this->app->DB->SelectArr($sql);
if (!empty($result)) {
return("Es existieren Buchungen, Eintrag wurde nicht als Importfehler markiert!");
} else {
$this->app->DB->Delete("UPDATE `kontoauszuege` SET importfehler = 1 WHERE `id` = '{$id}'");
return("Der Eintrag wurde als Importfehler markiert.");
}
return(null);
}
function kontoauszuege_list() {
@ -282,8 +296,21 @@ class Kontoauszuege {
$submit = $this->app->Secure->GetPOST('ausfuehren');
if ($submit == 'Importfehler') {
$sql = "UPDATE kontoauszuege SET importfehler = 1 WHERE id IN (".implode(",",$selectedIds).")";
$this->app->DB->Update($sql);
$message = "";
foreach ($selectedIds as $selectedId) {
$result = $this->kontoauszuege_mark_as_error($selectedId);
if ($result) {
$message = $result;
}
}
if ($message) {
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">".$message."</div>");
} else {
$this->app->Tpl->Set('MESSAGE', "<div class=\"warning\">Eintr&auml;ge wurden als Importfehler markiert.</div>");
}
}
}
@ -309,15 +336,14 @@ class Kontoauszuege {
public function kontoauszuege_delete() {
$id = (int) $this->app->Secure->GetGET('id');
$sql = "SELECT id FROM fibu_buchungen_alle WHERE CONCAT(doc_typ,doc_id) <> CONCAT('kontoauszuege','".$id."') AND typ = 'kontoauszuege' AND id = ".$id;
$result = $this->app->DB->SelectArr($sql);
$result = $this->kontoauszuege_mark_as_error($id);
if (!empty($result)) {
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Es existieren Buchungen, Eintrag wurde nicht als Importfehler markiert!</div>");
if ($result) {
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">".$result."</div>");
} else {
$this->app->DB->Delete("UPDATE `kontoauszuege` SET importfehler = 1 WHERE `id` = '{$id}'");
$this->app->Tpl->Set('MESSAGE', "<div class=\"warning\">Der Eintrag wurde als Importfehler markiert.</div>");
}
$this->kontoauszuege_list();
}

View File

@ -2065,23 +2065,6 @@ class Rechnung extends GenRechnung
$this->app->DB->Update("UPDATE rechnung SET zahlungsstatus='offen' WHERE zahlungsstatus=''");
// First refresh all open items
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from rechnung WHERE zahlungsstatus = 'offen'");
foreach ($openids as $openid) {
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'rechnung');
if (!empty($saldo)) {
if ($saldo['waehrung'] == $openid['waehrung']) {
$sql = "UPDATE rechnung SET ist = ".$saldo['betrag']."+soll WHERE id=".$openid['id'];
$this->app->DB->Update($sql);
}
}
else {
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$openid['id']);
}
}
if($this->app->Secure->GetPOST('ausfuehren') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
{
$drucker = $this->app->Secure->GetPOST('seldrucker');
@ -2262,6 +2245,28 @@ class Rechnung extends GenRechnung
}
}
// refresh all open items
$openids = $this->app->DB->SelectArr("SELECT id, waehrung from rechnung WHERE zahlungsstatus = 'offen'");
foreach ($openids as $openid) {
$saldo = $this->app->erp->GetSaldoDokument($openid['id'],'rechnung');
if (!empty($saldo)) {
if ($saldo['waehrung'] == $openid['waehrung']) {
$sql = "UPDATE
rechnung
SET
ist = ".$saldo['betrag']."+soll,
zahlungsstatus = IF(".$saldo['betrag']." = 0,'bezahlt','offen')
WHERE id=".$openid['id'];
$this->app->DB->Update($sql);
}
}
else {
$this->app->DB->Update("UPDATE rechnung SET ist = null WHERE id=".$openid['id']);
}
}
$this->app->Tpl->Set('UEBERSCHRIFT','Rechnungen');
$backurl = $this->app->Secure->GetGET('backurl');