471 lines
27 KiB
PHP
471 lines
27 KiB
PHP
<?php
|
|
$pagination_baseurl = $this->getUrl($Mod, "Index");
|
|
$pagination_baseurl_params = ["filter" => $filter];
|
|
$pagination_entity_name = "Rechnungen";
|
|
?>
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a>
|
|
</li>
|
|
<li class="breadcrumb-item active">Rechnungen</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Rechnungen</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col">
|
|
<a href="https://thetool.xinon.at/xfarm/" class="btn btn-primary" target="_blank"><i class="far fa-arrows-to-circle fa-fw"></i> Fakt-Rechnungen Import</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-8">
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<h4 class="header-title mb-3">Filter</h4>
|
|
|
|
<form method="get" action="<?=self::getUrl("Invoice")?>">
|
|
<div class="row">
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_invoice_number">Rechnungsnummer</label>
|
|
<input type="text" class="form-control" name="filter[invoice_number]" id="filter_invoice_number" value="<?=(array_key_exists("invoice_number", $filter)) ? $filter['invoice_number'] : ""?>"/>
|
|
</div>
|
|
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_customer_number">Kundennummer</label>
|
|
<input type="text" class="form-control" name="filter[customer_number]" id="filter_customer_number" value="<?=(array_key_exists("customer_number", $filter)) ? $filter['customer_number'] : ""?>"/>
|
|
</div>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_customer">Kunde</label>
|
|
<input type="text" class="form-control" name="filter[customer]" id="filter_customer" value="<?=(array_key_exists("customer", $filter)) ? $filter['customer'] : ""?>"/>
|
|
</div>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_address">Adresse</label>
|
|
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=(array_key_exists("address", $filter)) ? $filter['address'] : ""?>"/>
|
|
</div>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_invoice_date_from">Rechnungsdatum von</label>
|
|
<input type="text" class="form-control" name="filter[invoice_date_from]" id="filter_invoice_date_from" value="<?=(array_key_exists("invoice_date_from", $filter)) ? $filter['invoice_date_from'] : ""?>"/>
|
|
</div>
|
|
<div class="col-2">
|
|
<label class="form-label" for="filter_invoice_date_to">Rechnungsdatum bis</label>
|
|
<input type="text" class="form-control" name="filter[invoice_date_to]" id="filter_invoice_date_to" value="<?=(array_key_exists("invoice_date_to", $filter)) ? $filter['invoice_date_to'] : ""?>"/>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-12">
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-search"></i> Filter anwenden</button>
|
|
<a class="btn btn-secondary" href="<?=self::getUrl("Invoice")?>?resetFilter=1"><i class="fas fa-fw fa-xmark-large"></i> Filter zurücksetzen</a>
|
|
<button type="submit" name="export_type" value="bmd-credit" class="btn btn-outline-danger ml-4"><i class="far fa-fw fa-file-export"></i> Provisionsexport für BMD</button>
|
|
<button type="submit" name="export_type" value="bmd-invoice" class="btn btn-outline-primary ml-1"><i class="far fa-fw fa-file-export"></i> Rechnungsexport für BMD</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-4">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-8">
|
|
<h4>Rechnungsversand</h4>
|
|
<form method="post" action="<?=self::getUrl("Invoice","sendInvoices")?>">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label class="form-label" for="delivery_start_date">Rechungsdatum von</label>
|
|
<input type="text" class="form-control" name="delivery_start_date" id="delivery_start_date" value="" />
|
|
</div>
|
|
<div class="col-6">
|
|
<label class="form-label" for="delivery_end_date">Rechungsdatum bis</label>
|
|
<input type="text" class="form-control" name="delivery_end_date" id="delivery_end_date" value="" />
|
|
</div>
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-12">
|
|
<button name="type" value="paper" class="btn btn-lg btn-purple"><i class="far fa-fw fa-print"></i> Rechnungen für Postversand drucken</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-8">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<h4>PDFs erstellen</h4>
|
|
<form method="post" action="<?=self::getUrl("Invoice", "createJob")?>">
|
|
<input type="hidden" name="task" value="make-invoice-pdf" />
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<label class="form-label" for="from_date">Job Startdatum:</label>
|
|
<input type="text" class="form-control datepicker" name="from_date" value="" />
|
|
</div>
|
|
<div class="col-4">
|
|
<label class="form-label" for="to_date">Job Enddatum:</label>
|
|
<input type="text" class="form-control datepicker" name="to_date" value="" />
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary mt-1"><i class="fas fa-fw fa-circle-plus"></i> Job erstellen</button>
|
|
|
|
<?php if(is_array($pdf_jobs) && count($pdf_jobs)): ?>
|
|
<h5>Aktuelle PDF Jobs</h5>
|
|
<table class="table table-sm table-striped">
|
|
<tr>
|
|
<th>Von</th>
|
|
<th>Bis</th>
|
|
<th>Gestartet</th>
|
|
<th>Beendet</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
<?php foreach($pdf_jobs as $job): ?>
|
|
<tr id="job-<?=$job->id?>">
|
|
<td><?=$job->from_date?></td>
|
|
<td><?=$job->to_date?></td>
|
|
<td><?=$job->started?></td>
|
|
<td class="finished"><?=$job->finished?></td>
|
|
<td>
|
|
<strong class="status text-monospace <?=(($job->status == "finished") ? "text-success" : ($job->status == "timeout" ? "text-danger" : "text-info"))?>"><?=($job->status) ? $job->status : "neu"?></strong><br />
|
|
<span class="status-text"><?=$job->getResult("created") ? $job->getResult("created")." Rechungs-PDFs erstellt" : ""?></span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
</form>
|
|
</div>
|
|
<div class="col-6 border-left">
|
|
<h4>Rechungsemails versenden</h4>
|
|
<form method="post" action="<?=self::getUrl("Invoice", "createJob")?>">
|
|
<input type="hidden" name="task" value="send-invoice-email" />
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<label class="form-label" for="from_date">Job Startdatum:</label>
|
|
<input type="text" class="form-control datepicker" name="from_date" value="" />
|
|
</div>
|
|
<div class="col-4">
|
|
<label class="form-label" for="to_date">Job Enddatum:</label>
|
|
<input type="text" class="form-control datepicker" name="to_date" value="" />
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary mt-1"><i class="fas fa-fw fa-circle-plus"></i> Job erstellen</button>
|
|
|
|
<?php if(is_array($email_jobs) && count($email_jobs)): ?>
|
|
<h5>Aktuelle Email Jobs</h5>
|
|
<table class="table table-sm table-striped">
|
|
<tr>
|
|
<th>Von</th>
|
|
<th>Bis</th>
|
|
<th>Gestartet</th>
|
|
<th>Beendet</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
<?php foreach($email_jobs as $job): ?>
|
|
<tr id="job-<?=$job->id?>">
|
|
<td><?=$job->from_date?></td>
|
|
<td><?=$job->to_date?></td>
|
|
<td><?=$job->started?></td>
|
|
<td class="finished"><?=$job->finished?></td>
|
|
<td>
|
|
<strong class="status text-monospace <?=(($job->status == "finished") ? "text-success" : ($job->status == "timeout" ? "text-danger" : "text-info"))?>"><?=($job->status) ? $job->status : "neu"?></strong><br />
|
|
<span class="status-text"><?=$job->getResult("sent") ? $job->getResult("sent")." Emails versendet" : ""?></span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-4">
|
|
<div>
|
|
<table class="table table-sm table-striped table-bordered">
|
|
<tr>
|
|
<th class="text-right">
|
|
Summe Rechnungen Netto:<br/>
|
|
Summe Rechnungen Brutto:
|
|
</th>
|
|
<td class="text-monospace">
|
|
€ <?=number_format($sum_price, 2, ",", ".")?><br />
|
|
€ <?=number_format($sum_price_gross, 2, ",", ".")?>
|
|
</td>
|
|
</tr><tr>
|
|
<th class="text-right">
|
|
Summe Rechnungen Bankeinzug Netto:<br />
|
|
Summe Rechnungen Bankeinzug Brutto:
|
|
</th>
|
|
<td class="text-monospace">
|
|
€ <?=number_format($sum_price_sepa, 2, ",", ".")?><br />
|
|
€ <?=number_format($sum_price_sepa_gross, 2, ",", ".")?>
|
|
</td>
|
|
</tr><tr>
|
|
<th class="text-right">
|
|
Summe Gutschriften Netto:<br />
|
|
Summe Gutschriften Brutto:
|
|
</th>
|
|
<td class="text-monospace">
|
|
€ <?=number_format($sum_credit_price, 2, ",", ".")?><br />
|
|
€ <?=number_format($sum_credit_price_gross, 2, ",", ".")?>
|
|
</td>
|
|
</tr><tr>
|
|
<th class="text-right">
|
|
Summe Gesprächsgebühren Netto:<br />
|
|
Summe Gesprächsgebühren Brutto:
|
|
</th>
|
|
<td class="text-monospace">
|
|
€ <?=number_format($sum_voicecalls_price, 2, ",", ".")?><br />
|
|
€ <?=number_format($sum_voicecalls_price_gross, 2, ",", ".")?>
|
|
</td>
|
|
</tr><tr>
|
|
<th class="text-right">
|
|
Summe Gesprächsgebühren Bankeinzug Netto:<br />
|
|
Summe Gesprächsgebühren Bankeinzug Brutto:
|
|
</th>
|
|
<td class="text-monospace">
|
|
€ <?=number_format($sum_voicecalls_price_sepa, 2, ",", ".")?><br />
|
|
€ <?=number_format($sum_voicecalls_price_sepa_gross, 2, ",", ".")?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h4 class="header-title">Rechnungen</h4>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
|
|
<table class="table table-sm table-striped table-hover">
|
|
<tr>
|
|
<th>Rechungsnummer</th>
|
|
<th>Rechnungsdatum</th>
|
|
<th>Kundennummer</th>
|
|
<th>Rechnungsadresse</th>
|
|
<th>Netto</th>
|
|
<th>Ust.</th>
|
|
<th>Brutto</th>
|
|
<th>Zahlung</th>
|
|
<th>Zustellung</th>
|
|
<th></th>
|
|
</tr>
|
|
<?php foreach($invoices as $invoice): ?>
|
|
<?php $total = $invoice->total + $invoice->total_setup; ?>
|
|
<?php $total_gross = $invoice->total_gross + $invoice->total_setup_gross; ?>
|
|
<tr>
|
|
<td>
|
|
<a href="<?=self::getUrl("Invoice", "downloadInvoice", ["id" => $invoice->id])?>"><i class="fas fa-download fa-fw"></i> <?=$invoice->invoice_number?></a>
|
|
<?php if($invoice->pdf): ?>
|
|
<i class="fas fa-fw fa-check" title="PDF generiert"></i>
|
|
<?php endif; ?>
|
|
<?php if($invoice->date_delivered): ?>
|
|
<i class="fas fa-fw fa-mail" title="per Email versendet am <?=date("d.m.Y H:i", $invoice->date_delivered)?>"></i>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?=date("d.m.Y", $invoice->invoice_date)?></td>
|
|
<td><?=$invoice->customer_number?></td>
|
|
<td>
|
|
<?=($invoice->company) ? $invoice->company."<br />" : ""?>
|
|
<?=($invoice->firstname || $invoice->lastname) ? $invoice->firstname." ".$invoice->lastname."<br />" : ""?>
|
|
<?=$invoice->street?><br />
|
|
<?=$invoice->zip?> <?=$invoice->city?><br />
|
|
<?=$invoice->country?>
|
|
</td>
|
|
<td class="<?=($total < 0) ? "text-danger" : ""?>">€ <?=number_format($total,2,",",".")?></td>
|
|
<td >€ <?=number_format($total_gross - $total,2,",",".")?></td>
|
|
<td class="<?=($total_gross < 0) ? "text-danger" : ""?>">€ <?=number_format($total_gross,2,",",".")?></td>
|
|
<td><?=($invoice->billing_type == "sepa") ? "SEPA" : "Überweisung"?></td>
|
|
<td><?=($invoice->billing_delivery == "email") ? "Email" : "Papier"?></td>
|
|
<td>
|
|
<a href="<?=self::getUrl("Invoice", "downloadInvoiceCsv", ["id" => $invoice->id])?>" title="CSV-Download"><i class="fas fa-file-csv fa-fw"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
$('#delivery_start_date').datepicker({
|
|
orientation: "bottom",
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
$('#delivery_end_date').datepicker({
|
|
orientation: "bottom",
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
|
|
$('#filter_invoice_date_from').datepicker({
|
|
orientation: "bottom",
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
$('#filter_invoice_date_to').datepicker({
|
|
orientation: "bottom",
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
$('.datepicker').datepicker({
|
|
orientation: "bottom",
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
|
|
var status_update;
|
|
|
|
function updateStatus() {
|
|
$.post(
|
|
"<?=self::getUrl("InvoiceJob", "api")?>",
|
|
{
|
|
do: "getActiveJobs"
|
|
},
|
|
function(success) {
|
|
if(success.status != "OK") return;
|
|
|
|
jobs = success.result.jobs;
|
|
jobs.forEach((job) => {
|
|
let status = JSON.parse(job.result);
|
|
if(!status) return;
|
|
|
|
let status_text = "";
|
|
let count = 0;
|
|
|
|
if(job.task == "make-invoice-pdf") {
|
|
status_text = status.created + " Emails versendet";
|
|
count = status.created;
|
|
} else if(job.task == "send-invoice-email") {
|
|
status_text = status.sent + " Emails versendet";
|
|
count = status.sent;
|
|
}
|
|
|
|
let old_count = 0;
|
|
let m = $("#job-" + job.id + " .status-text").text().match(/^(\d+)/);
|
|
if(m) {
|
|
old_count = m[1];
|
|
}
|
|
if(old_count != count) {
|
|
$("#job-" + job.id + " .status-text").fadeOut();
|
|
$("#job-" + job.id + " .status-text").promise().done(() => {$("#job-" + job.id + " .status-text").text(status_text).fadeIn()});
|
|
}
|
|
|
|
$("#job-" + job.id + " .status").text(job.status ? job.status : "neu");
|
|
if(job.status == "timeout") {
|
|
$("#job-" + job.id + " .status").removeClass("text-info text-success").addClass("text-danger");
|
|
} else if(job.status == "finished") {
|
|
$("#job-" + job.id + " .status").removeClass("text-info text-danger").addClass("text-success");
|
|
} else {
|
|
$("#job-" + job.id + " .status").removeClass("text-danger text-success").addClass("text-info");
|
|
}
|
|
|
|
if(job.finished) {
|
|
$("#job-" + job.id + " .finished").text(job.finished);
|
|
} else {
|
|
$("#job-" + job.id + " .finished").text("");
|
|
}
|
|
});
|
|
|
|
status_update = setTimeout(updateStatus, 2000);
|
|
},
|
|
"json"
|
|
);
|
|
}
|
|
|
|
$(document).ready(() => {
|
|
<?php if((is_array($pdf_jobs) && count($pdf_jobs)) || (is_array($email_jobs)) && count($email_jobs)): ?>
|
|
status_update = setTimeout(updateStatus, 1000);
|
|
<?php endif; ?>
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|