WIP Invoice Email delivery
This commit is contained in:
@@ -79,7 +79,7 @@ $pagination_entity_name = "Rechnungen";
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h4>Rechnungsversand</h4>
|
||||
<form method="post" action="<?=self::getUrl("Invoice","printInvoices")?>">
|
||||
<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>
|
||||
|
||||
@@ -713,7 +713,58 @@ class InvoiceController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function printInvoicesAction() {
|
||||
protected function sendInvoices() {
|
||||
$r = $this->request;
|
||||
$type = $r->type;
|
||||
|
||||
if($type == "email") {
|
||||
return $this->sendEmailInvoices();
|
||||
}
|
||||
if($type == "paper") {
|
||||
return $this->printInvoices();
|
||||
}
|
||||
|
||||
$this->redirect("Invoice");
|
||||
}
|
||||
|
||||
public function sendEmailInvoices() {
|
||||
$r = $this->request;
|
||||
$start = $r->delivery_start_date;
|
||||
$end = $r->delivery_end_date;
|
||||
|
||||
try {
|
||||
$start_date = DateTime::createFromFormat("d.m.Y", $start, new DateTimeZone("Europe/Vienna"));
|
||||
$start_date->setTime(0,0,0);
|
||||
|
||||
$end_date = DateTime::createFromFormat("d.m.Y", $end, new DateTimeZone("Europe/Vienna"));
|
||||
$end_date->setTime(23,59,59);
|
||||
} catch(Exception $e) {
|
||||
$this->layout()->setFlash("Von- oder Bisdatum ungültig", "error");
|
||||
$this->redirect("Invoice");
|
||||
}
|
||||
|
||||
if(!InvoiceModel::count(["billing_delivery" => "email", "date_delivered" => false, "invoice_date>=" => $start_date->getTimestamp(), "invoice_date<=" => $end_date->getTimestamp()])) {
|
||||
$this->layout()->setFlash("Keine Rechnungen im angegebenen Zeitraum gefunden", "error");
|
||||
$this->redirect("Invoice");
|
||||
}
|
||||
|
||||
foreach(InvoiceModel::search(["billing_delivery" => "email", "date_delivered" => false, "invoice_date>=" => $start_date->getTimestamp(), "invoice_date<=" => $end_date->getTimestamp()]) as $invoice) {
|
||||
var_dump($invoice);exit;
|
||||
|
||||
$pdf = $invoice->pdf;
|
||||
if(!file_exists($pdf_file)) {
|
||||
$this->layout()->setFlash("Datei ".$pdf->filename." nicht gefunden", "error");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function printInvoices() {
|
||||
return false;
|
||||
$start = $this->request->delivery_start_date;
|
||||
$end = $this->request->delivery_end_date;
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$ic = new InvoiceController(false);
|
||||
$ic->createPDFs();
|
||||
Reference in New Issue
Block a user