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/class/html.formother.class.php'; dol_include_once('/steuer/class/buchung.class.php'); $langs->loadLangs(array("steuer@steuer", "bills", "compta")); $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Objekt initialisieren $object = new SteuerBuchung($db); // Laden, wenn ID oder Ref if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); } /* * Actions */ if ($cancel) { if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } // Neue Buchung erstellen if ($action == 'add' && !$cancel) { $error = 0; $object->datum = dol_mktime(0, 0, 0, GETPOSTINT('datummonth'), GETPOSTINT('datumday'), GETPOSTINT('datumyear')); $object->belegnummer = GETPOST('belegnummer', 'alpha'); $object->beschreibung = GETPOST('beschreibung', 'alpha'); $object->fk_konto = GETPOSTINT('fk_konto'); $object->typ = GETPOST('typ', 'alpha'); $object->ust_satz = GETPOSTFLOAT('ust_satz'); $object->zahlungsart = GETPOST('zahlungsart', 'alpha'); $object->fk_soc = GETPOSTINT('fk_soc'); $object->note_private = GETPOST('note_private', 'restricthtml'); // Betrag berechnen $betrag_eingabe = GETPOST('betrag_eingabe', 'alpha'); $betrag = price2num(GETPOST('betrag', 'alpha')); if ($betrag_eingabe == 'brutto') { $object->betrag_brutto = $betrag; $object->betrag_netto = $betrag / (1 + $object->ust_satz / 100); $object->betrag_ust = $object->betrag_brutto - $object->betrag_netto; } else { $object->betrag_netto = $betrag; $object->betrag_ust = $betrag * $object->ust_satz / 100; $object->betrag_brutto = $object->betrag_netto + $object->betrag_ust; } // Validierung if (empty($object->datum)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesaliases("Date")), null, 'errors'); $error++; } if (empty($object->beschreibung)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesaliases("Description")), null, 'errors'); $error++; } if (empty($object->fk_konto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesaliases("Account")), null, 'errors'); $error++; } if ($betrag <= 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesaliases("Amount")), null, 'errors'); $error++; } if (!$error) { $result = $object->create($user); if ($result > 0) { setEventMessages($langs->trans("BuchungCreated"), null, 'mesgs'); header("Location: ".dol_buildpath('/steuer/buchung_card.php', 1).'?id='.$result); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } } else { $action = 'create'; } } // Buchung aktualisieren if ($action == 'update' && !$cancel) { $error = 0; $object->datum = dol_mktime(0, 0, 0, GETPOSTINT('datummonth'), GETPOSTINT('datumday'), GETPOSTINT('datumyear')); $object->belegnummer = GETPOST('belegnummer', 'alpha'); $object->beschreibung = GETPOST('beschreibung', 'alpha'); $object->fk_konto = GETPOSTINT('fk_konto'); $object->typ = GETPOST('typ', 'alpha'); $object->ust_satz = GETPOSTFLOAT('ust_satz'); $object->zahlungsart = GETPOST('zahlungsart', 'alpha'); $object->fk_soc = GETPOSTINT('fk_soc'); $object->note_private = GETPOST('note_private', 'restricthtml'); // Betrag berechnen $betrag_eingabe = GETPOST('betrag_eingabe', 'alpha'); $betrag = price2num(GETPOST('betrag', 'alpha')); if ($betrag_eingabe == 'brutto') { $object->betrag_brutto = $betrag; $object->betrag_netto = $betrag / (1 + $object->ust_satz / 100); $object->betrag_ust = $object->betrag_brutto - $object->betrag_netto; } else { $object->betrag_netto = $betrag; $object->betrag_ust = $betrag * $object->ust_satz / 100; $object->betrag_brutto = $object->betrag_netto + $object->betrag_ust; } if (!$error) { $result = $object->update($user); if ($result > 0) { setEventMessages($langs->trans("BuchungUpdated"), null, 'mesgs'); header("Location: ".dol_buildpath('/steuer/buchung_card.php', 1).'?id='.$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } } else { $action = 'edit'; } } // Löschen bestätigen if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($user); if ($result > 0) { setEventMessages($langs->trans("BuchungDeleted"), null, 'mesgs'); header("Location: ".dol_buildpath('/steuer/buchung_list.php', 1)); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } /* * View */ $form = new Form($db); $title = $langs->trans("Buchung"); if ($action == 'create') { $title = $langs->trans("NeueBuchung"); } llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-steuer page-buchung-card'); // Konten laden $konten_einnahmen = SteuerBuchung::getKonten($db, 'einnahme'); $konten_ausgaben = SteuerBuchung::getKonten($db, 'ausgabe'); $konten_alle = SteuerBuchung::getKonten($db); // USt-Sätze $ust_saetze = array( 0 => '0% (steuerfrei)', 7 => '7% (ermäßigt)', 19 => '19% (Regelsteuersatz)' ); // Zahlungsarten $zahlungsarten = array( 'bank' => $langs->trans("Bank"), 'bar' => $langs->trans("Cash"), 'paypal' => 'PayPal', 'kreditkarte' => $langs->trans("CreditCard"), 'lastschrift' => $langs->trans("DirectDebit"), 'sonstige' => $langs->trans("Other") ); // Buchungstypen $typen = array( 'einnahme' => $langs->trans("Einnahme"), 'ausgabe' => $langs->trans("Ausgabe") ); // Formular: Neue Buchung oder Bearbeiten if ($action == 'create' || $action == 'edit') { print load_fiche_titre($action == 'create' ? $langs->trans("NeueBuchung") : $langs->trans("EditBuchung"), '', 'steuer.png@steuer'); print '
'; print ''; print ''; if ($action == 'edit') { print ''; } if ($backtopage) { print ''; } print dol_get_fiche_head(array(), '', '', 0, ''); print ''; // Typ (Einnahme/Ausgabe) print ''; // Datum print ''; // Belegnummer print ''; // Beschreibung print ''; // Konto print ''; // Betrag print ''; // USt-Satz print ''; // Zahlungsart print ''; // Kunde/Lieferant print ''; // Notiz print ''; print '
'.$langs->trans("Typ").''; print $form->selectarray('typ', $typen, GETPOSTISSET('typ') ? GETPOST('typ') : $object->typ, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'); print '
'.$langs->trans("Date").''; print $form->selectDate(GETPOSTISSET('datumday') ? dol_mktime(0, 0, 0, GETPOSTINT('datummonth'), GETPOSTINT('datumday'), GETPOSTINT('datumyear')) : ($object->datum ? $object->datum : dol_now()), 'datum', 0, 0, 0, '', 1, 1); print '
'.$langs->trans("Belegnummer").''; print ''; print '
'.$langs->trans("Description").''; print ''; print '
'.$langs->trans("Account").''; print $form->selectarray('fk_konto', $konten_alle, GETPOSTISSET('fk_konto') ? GETPOSTINT('fk_konto') : $object->fk_konto, 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1); print '
'.$langs->trans("Amount").''; $betrag_wert = GETPOSTISSET('betrag') ? GETPOST('betrag') : ($object->betrag_brutto > 0 ? $object->betrag_brutto : ''); print ' EUR '; print ''; print '
'.$langs->trans("VATRate").''; print $form->selectarray('ust_satz', $ust_saetze, GETPOSTISSET('ust_satz') ? GETPOST('ust_satz') : ($object->ust_satz !== null ? (int)$object->ust_satz : 19), 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'); print '
'.$langs->trans("PaymentMode").''; print $form->selectarray('zahlungsart', $zahlungsarten, GETPOSTISSET('zahlungsart') ? GETPOST('zahlungsart') : $object->zahlungsart, 1, 0, 0, '', 0, 0, 0, '', 'minwidth200'); print '
'.$langs->trans("ThirdParty").''; print $form->select_company(GETPOSTISSET('fk_soc') ? GETPOSTINT('fk_soc') : $object->fk_soc, 'fk_soc', '', 1, 0, 0, array(), 0, 'minwidth300'); print '
'.$langs->trans("Note").''; print ''; print '
'; print dol_get_fiche_end(); print '
'; print ''; print '   '; print ''; print '
'; print '
'; } elseif ($object->id > 0) { // Anzeige der Buchung // Löschen bestätigen if ($action == 'delete') { print $form->formconfirm( $_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteBuchung"), $langs->trans("ConfirmDeleteBuchung"), 'confirm_delete', '', 0, 1 ); } print load_fiche_titre($langs->trans("Buchung").' '.$object->ref, '', 'steuer.png@steuer'); print dol_get_fiche_head(array(), '', '', 0, ''); print ''; // Referenz print ''; print ''; // Typ print ''; print ''; // Datum print ''; print ''; // Belegnummer print ''; print ''; // Beschreibung print ''; print ''; // Konto print ''; print ''; // Beträge print ''; print ''; print ''; print ''; print ''; print ''; // Zahlungsart if ($object->zahlungsart) { print ''; print ''; } // Kunde/Lieferant if ($object->fk_soc > 0) { $soc = new Societe($db); $soc->fetch($object->fk_soc); print ''; print ''; } // Notiz if ($object->note_private) { print ''; print ''; } // Erstellt am/von print ''; print ''; print '
'.$langs->trans("Ref").''.$object->ref.'
'.$langs->trans("Typ").''.$typen[$object->typ].'
'.$langs->trans("Date").''.dol_print_date($object->datum, 'day').'
'.$langs->trans("Belegnummer").''.$object->belegnummer.'
'.$langs->trans("Description").''.$object->beschreibung.'
'.$langs->trans("Account").''.$object->konto_nummer.' - '.$object->konto_bezeichnung.'
'.$langs->trans("AmountHT").' (Netto)'.price($object->betrag_netto, 0, $langs, 1, 2, 2, 'EUR').'
'.$langs->trans("VAT").' ('.(int)$object->ust_satz.'%)'.price($object->betrag_ust, 0, $langs, 1, 2, 2, 'EUR').'
'.$langs->trans("AmountTTC").' (Brutto)'.price($object->betrag_brutto, 0, $langs, 1, 2, 2, 'EUR').'
'.$langs->trans("PaymentMode").''.(isset($zahlungsarten[$object->zahlungsart]) ? $zahlungsarten[$object->zahlungsart] : $object->zahlungsart).'
'.$langs->trans("ThirdParty").''.$soc->getNomUrl(1).'
'.$langs->trans("Note").''.nl2br($object->note_private).'
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, 'dayhour').'
'; print dol_get_fiche_end(); // Aktionen print '
'; print ''.$langs->trans("Back").''; print ''.$langs->trans("Modify").''; print ''.$langs->trans("Delete").''; print '
'; } else { // Keine Buchung gefunden print $langs->trans("RecordNotFound"); print '

'; print '
'; print ''.$langs->trans("Back").''; print '
'; } llxFooter(); $db->close();