0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; dol_include_once('/steuer/class/buchung.class.php'); dol_include_once('/steuer/class/euer.class.php'); $langs->loadLangs(array("steuer@steuer", "bills", "compta")); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Filter $jahr = GETPOSTINT('jahr'); if (empty($jahr)) { $jahr = date('Y'); } $monat = GETPOSTINT('monat'); $typ = GETPOST('search_typ', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_beschreibung = GETPOST('search_beschreibung', 'alpha'); // Sortierung $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); if (empty($sortfield)) { $sortfield = 'datum'; } if (empty($sortorder)) { $sortorder = 'DESC'; } // Pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page'); if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; /* * View */ $form = new Form($db); $euer = new EUeR($db); llxHeader('', $langs->trans("Buchungen"), '', '', 0, 0, '', '', '', 'mod-steuer page-buchung-list'); print load_fiche_titre($langs->trans("Buchungen"), '', 'steuer.png@steuer'); // Datumsgrenzen für SQL if ($monat > 0) { $datum_von = $jahr.'-'.sprintf('%02d', $monat).'-01'; $datum_bis = date('Y-m-t', strtotime($datum_von)); } else { $datum_von = $jahr.'-01-01'; $datum_bis = $jahr.'-12-31'; } // SQL für manuelle Buchungen $sql = "SELECT b.rowid, b.ref, b.datum, b.belegnummer, b.beschreibung,"; $sql .= " b.betrag_netto, b.betrag_ust, b.betrag_brutto, b.typ,"; $sql .= " k.kontonummer, k.bezeichnung as konto_bezeichnung,"; $sql .= " 'manuell' as quelle"; $sql .= " FROM ".MAIN_DB_PREFIX."steuer_buchung as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."steuer_konto as k ON b.fk_konto = k.rowid"; $sql .= " WHERE b.entity = ".((int) $conf->entity); $sql .= " AND b.status = 1"; $sql .= " AND b.datum BETWEEN '".$db->escape($datum_von)."' AND '".$db->escape($datum_bis)."'"; if ($typ) { $sql .= " AND b.typ = '".$db->escape($typ)."'"; } if ($search_ref) { $sql .= " AND b.ref LIKE '%".$db->escape($search_ref)."%'"; } if ($search_beschreibung) { $sql .= " AND b.beschreibung LIKE '%".$db->escape($search_beschreibung)."%'"; } // UNION mit Rechnungen (Einnahmen) $sql .= " UNION ALL "; $sql .= "SELECT f.rowid, f.ref, COALESCE(pf.datep, f.datef) as datum, f.ref as belegnummer,"; $sql .= " CONCAT('Rechnung: ', s.nom) as beschreibung,"; $sql .= " f.total_ht as betrag_netto, f.total_tva as betrag_ust, f.total_ttc as betrag_brutto,"; $sql .= " 'einnahme' as typ, '' as kontonummer, '' as konto_bezeichnung,"; $sql .= " 'facture' as quelle"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid"; $sql .= " WHERE f.entity = ".((int) $conf->entity); $sql .= " AND f.fk_statut IN (2, 3)"; $sql .= " AND COALESCE(pf.datep, f.datef) BETWEEN '".$db->escape($datum_von)."' AND '".$db->escape($datum_bis)."'"; if ($typ == 'ausgabe') { $sql .= " AND 1=0"; // Keine Einnahmen bei Ausgaben-Filter } if ($search_beschreibung) { $sql .= " AND s.nom LIKE '%".$db->escape($search_beschreibung)."%'"; } $sql .= " GROUP BY f.rowid"; // UNION mit Lieferantenrechnungen (Ausgaben) $sql .= " UNION ALL "; $sql .= "SELECT f.rowid, f.ref, COALESCE(pf.datep, f.datef) as datum, COALESCE(f.ref_supplier, f.ref) as belegnummer,"; $sql .= " CONCAT('Lieferant: ', s.nom) as beschreibung,"; $sql .= " f.total_ht as betrag_netto, f.total_tva as betrag_ust, f.total_ttc as betrag_brutto,"; $sql .= " 'ausgabe' as typ, '' as kontonummer, '' as konto_bezeichnung,"; $sql .= " 'facture_fourn' as quelle"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid"; $sql .= " WHERE f.entity = ".((int) $conf->entity); $sql .= " AND f.fk_statut IN (2)"; $sql .= " AND COALESCE(pf.datep, f.datef) BETWEEN '".$db->escape($datum_von)."' AND '".$db->escape($datum_bis)."'"; if ($typ == 'einnahme') { $sql .= " AND 1=0"; // Keine Ausgaben bei Einnahmen-Filter } if ($search_beschreibung) { $sql .= " AND s.nom LIKE '%".$db->escape($search_beschreibung)."%'"; } $sql .= " GROUP BY f.rowid"; // Sortierung und Limit $sql_count = "SELECT COUNT(*) as total FROM (".$sql.") as combined"; $sql .= " ORDER BY ".$sortfield." ".$sortorder; $sql .= " LIMIT ".$limit." OFFSET ".$offset; // Gesamtzahl ermitteln $resql_count = $db->query($sql_count); $nbtotalofrecords = 0; if ($resql_count) { $obj = $db->fetch_object($resql_count); $nbtotalofrecords = $obj->total; } // Filter-Formular print '
'; // Zusammenfassung print '| '.$langs->trans("Summary").' '.$jahr.' | '; print '|
|---|---|
| '.$langs->trans("TotalEinnahmen").' | '; print ''.price($total_einnahmen, 0, $langs, 1, 2, 2, 'EUR').' | '; print '
| '.$langs->trans("TotalAusgaben").' | '; print ''.price($total_ausgaben, 0, $langs, 1, 2, 2, 'EUR').' | '; print '
| '.($gewinn >= 0 ? $langs->trans("Gewinn") : $langs->trans("Verlust")).' | '; print ''.price($gewinn, 0, $langs, 1, 2, 2, 'EUR').' | '; print '