Added sums to Invoice/Index
This commit is contained in:
@@ -125,16 +125,16 @@ $pagination_entity_name = "Billingrecords";
|
||||
<table class="table table-sm table-striped table-bordered">
|
||||
<tr>
|
||||
<th class="text-right">Summe Rechnungen Periodisch:</th>
|
||||
<td>€ <?=number_format($sum_price, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($sum_price, 2, ",", ".")?></td>
|
||||
</tr><tr>
|
||||
<th class="text-right">Summe Rechnungen Einmalig:</th>
|
||||
<td>€ <?=number_format($sum_price_setup, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($sum_price_setup, 2, ",", ".")?></td>
|
||||
</tr><tr>
|
||||
<th class="text-right">Summe Gutschriften Periodisch:</th>
|
||||
<td>€ <?=number_format($sum_credit_price, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($sum_credit_price, 2, ",", ".")?></td>
|
||||
</tr><tr>
|
||||
<th class="text-right">Summe Gutschriften Einmalig:</th>
|
||||
<td>€ <?=number_format($sum_credit_price_setup, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($sum_credit_price_setup, 2, ",", ".")?></td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
|
||||
@@ -122,6 +122,63 @@ $pagination_entity_name = "Rechnungen";
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-end">
|
||||
<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 class="row">
|
||||
<div class="col-12">
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
@@ -56,6 +56,29 @@ class InvoiceController extends mfBaseController {
|
||||
|
||||
$this->layout()->set("invoices", $billings);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
$sum_price = InvoiceModel::getSumPrice($filter);
|
||||
$sum_price_gross = InvoiceModel::getSumGrossPrice($filter);
|
||||
$sum_price_sepa = InvoiceModel::getSumPrice(array_merge($filter, ["billing_type" => "sepa"]));
|
||||
$sum_price_sepa_gross = InvoiceModel::getSumGrossPrice(array_merge($filter, ["billing_type" => "sepa"]));
|
||||
$sum_credit_price = InvoiceModel::getSumCreditPrice($filter);
|
||||
$sum_credit_price_gross = InvoiceModel::getSumCreditGrossPrice();
|
||||
|
||||
$sum_voicecalls_price = InvoiceModel::getSumVoicecallsPrice($filter);
|
||||
$sum_voicecalls_price_gross = InvoiceModel::getSumVoicecallsGrossPrice($filter);
|
||||
$sum_voicecalls_price_sepa = InvoiceModel::getSumVoicecallsPrice(array_merge($filter, ["billing_type" => "sepa"]));
|
||||
$sum_voicecalls_price_sepa_gross = InvoiceModel::getSumVoicecallsGrossPrice(array_merge($filter, ["billing_type" => "sepa"]));
|
||||
|
||||
$this->layout()->set("sum_price", $sum_price);
|
||||
$this->layout()->set("sum_price_sepa", $sum_price_sepa);
|
||||
$this->layout()->set("sum_price_gross", $sum_price_gross);
|
||||
$this->layout()->set("sum_price_sepa_gross", $sum_price_sepa_gross);
|
||||
$this->layout()->set("sum_credit_price", $sum_credit_price);
|
||||
$this->layout()->set("sum_credit_price_gross", $sum_credit_price_gross);
|
||||
$this->layout()->set("sum_voicecalls_price", $sum_voicecalls_price);
|
||||
$this->layout()->set("sum_voicecalls_price_gross", $sum_voicecalls_price_gross);
|
||||
$this->layout()->set("sum_voicecalls_price_sepa", $sum_voicecalls_price_sepa);
|
||||
$this->layout()->set("sum_voicecalls_price_sepa_gross", $sum_voicecalls_price_sepa_gross);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
|
||||
@@ -109,6 +109,130 @@ class InvoiceModel {
|
||||
return $last_invoice->invoice_number;
|
||||
}
|
||||
|
||||
public static function getSumPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(total) as p FROM Invoice WHERE total > 0 AND $where";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getSumGrossPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(total_gross) as p FROM Invoice WHERE total_gross > 0 AND $where";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getSumCreditPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(total) as p FROM Invoice WHERE total < 0 AND $where";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getSumCreditGrossPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(total_gross) as p FROM Invoice WHERE total_gross < 0 AND $where";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getSumVoicecallsPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(Invoiceposition.price) as p FROM Invoiceposition
|
||||
LEFT JOIN Invoice ON (Invoice.id = Invoiceposition.invoice_id)
|
||||
WHERE Invoiceposition.product_name LIKE 'Gesprächsgebühren %'
|
||||
AND $where
|
||||
";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getSumVoicecallsGrossPrice($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
if(array_key_exists("price>=", $filter)) unset($filter["price>="]);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT SUM(Invoiceposition.price_gross) as p FROM Invoiceposition
|
||||
LEFT JOIN Invoice ON (Invoice.id = Invoiceposition.invoice_id)
|
||||
WHERE Invoiceposition.product_name LIKE 'Gesprächsgebühren %'
|
||||
AND $where
|
||||
";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
return $data->p;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user