Merge branch 'fronkdev' of code.fronk.at:fronk/thetool into fronkdev

This commit is contained in:
Frank Schubert
2024-09-20 13:09:15 +02:00
11 changed files with 158 additions and 23 deletions

View File

@@ -41,6 +41,15 @@
<input type="text" class="form-control" name="filter[subject]" id="filter_betreff" value="<?=$filter['subject']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_is_include">Betreff</label>
<select class="form-control" name="filter[is_include]" id="filter_is_include">
<option></option>
<option value="0" <?=(array_key_exists("is_include", $filter) && $filter["is_include"] == 0) ? "selected='selected'" : ""?>>Dokumente</option>
<option value="1" <?=(array_key_exists("is_include", $filter) && $filter["is_include"] == 1) ? "selected='selected'" : ""?>>Templates</option>
</select>
</div>
</div>
<div class="row mt-2">
@@ -66,6 +75,7 @@
<table class="table table-striped table-hover">
<tr>
<th>Typ</th>
<th>Code</th>
<th>Name</th>
<th>Beschreibung</th>
@@ -77,13 +87,14 @@
</tr>
<?php foreach($templates as $template): ?>
<tr>
<td title="<?=($template->is_include) ? "Template" : "Dokument"?>"><i class="far fa-fw <?=($template->is_include) ? "fa-grip-lines text-info" : "fa-file-lines text-primary"?>"></i></td>
<td class="text-monospace text-monospace-valign-fix text-pink " style="max-width: 15vh"><div><?=$template->code?></div></td>
<td><?=$template->name?></td>
<td><?=$template->description?></td>
<td><?=$template->subject?></td>
<td><?=count($template->files)?></td>
<td><?=date("d.m.Y H:i",$template->edit)?> (<?=$template->editor->name?>)</td>
<td><?=date("d.m.Y H:i",$template->create)?> (<?=$template->creator->name?>)</td>
<td><?=date("d.m.Y H:i",$template->create)?> (<?=$template->editor->name?>)</td>
<td><?=date("d.m.Y H:i",$template->edit)?> (<?=$template->creator->name?>)</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Mailtemplate", "edit", ["id" => $template->id])?>"><i class="far fa-edit" title="Emailtemplate bearbeiten"></i></a>
<a href="<?=self::getUrl("Mailtemplate", "delete", ["id" => $template->id])?>" class="text-danger" onclick="if(!confirm('Emailtemplate wirklich löschen?')) return false;" title="Emailtemplate Löschen"><i class="fas fa-trash"></i></a>

View File

@@ -1047,12 +1047,13 @@ class PreorderApicontroller extends mfBaseApicontroller {
}
$return['status'] = $preorder->status->getApiArray();
foreach($preorder->statusflags as $sflag) {
$return['status']['flags'][$sflag->code] = [
$return['status']['flags'][] = [
"code" => (int)$sflag->code,
"text" => $sflag->name,
"value" => ($sflag->value->value == 1)
];
}
//var_dump($return['status']);exit;
if($addon_data) {
$return["additionalData"] = $addon_data;
}

View File

@@ -122,6 +122,18 @@ class Emailnotification {
//$log->debug(print_r($headers, true));
$mail =& Mail::factory('mail', ["-f ".$this->email_from]);
/*
* PHP 8's mail() function now outputs proper line endings in headers (CRLF instead of LF).
* Mail_mail < 2.0 would detect a unix system and change the headers line ending to LF.
* On Mail submission to Exim (via sendmail), mail() adds its own headers first with CRLF line ending,
* making Exim treat every subsequent header's LF as an invalid line ending, adding a whitespace after the LF,
* making all our custom headers into one long header.
*
* See: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-message_processing.html#SECTlineendings
*
* So we force CRLF line endings for headers here.
*/
$mail->sep = "\r\n";
$mail->send($this->email_to, $headers, $body);
}

View File

@@ -837,7 +837,7 @@ class InvoiceController extends mfBaseController {
public function createPDFs($limit = false) {
$invoice_path_base = MFUPLOAD_FILE_SAVE_PATH."/".TT_INVOICE_SAVE_SUBFOLDER;
$created = 0;
foreach(InvoiceModel::getAll() as $invoice) {
foreach(InvoiceModel::search(["invoice_file" => false]) as $invoice) {
if($limit && $created >= $limit) {
return $created;
}

View File

@@ -238,7 +238,11 @@ class InvoiceModel {
$db = FronkDB::singleton();
$res = $db->select("Invoice", "*", "1 = 1 ORDER BY invoice_number");
$sql = "SELECT Invoice.* FROM Invoice
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
ORDER BY invoice_number";
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Invoice($data);
@@ -252,7 +256,8 @@ class InvoiceModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM Invoice
$sql = "SELECT Invoice.* FROM Invoice
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
WHERE $where
ORDER BY invoice_number LIMIT 1";
//var_dump($sql);exit;
@@ -273,7 +278,8 @@ class InvoiceModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM Invoice
$sql = "SELECT Invoice.* FROM Invoice
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
WHERE $where
ORDER BY invoice_number DESC LIMIT 1";
@@ -297,6 +303,7 @@ class InvoiceModel {
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM Invoice
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
WHERE $where";
mfLoghandler::singleton()->debug($sql);
@@ -320,7 +327,8 @@ class InvoiceModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM Invoice
$sql = "SELECT Invoice.* FROM Invoice
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
WHERE $where
ORDER BY $order";
@@ -358,6 +366,15 @@ class InvoiceModel {
}
}
if(array_key_exists("invoice_file", $filter)) {
$invoice_file = $filter['invoice_file'];
if($invoice_file === true) {
$where .= " AND InvoiceFile.id > 0'";
} elseif($invoice_file === false || $invoice_file === null) {
$where .= " AND InvoiceFile.id IS NULL";
}
}
if(array_key_exists("invoice_number", $filter)) {
$invoice_number = $filter['invoice_number'];
if($invoice_number === true) {

View File

@@ -11,19 +11,55 @@ class Mailtemplate extends mfBaseModel {
}
public function getVariableReplacedBody($replaceVars) {
return $this->replaceVariables($this->body, $replaceVars);
$body = $this->body_html ? $this->body_html : $this->body_text;
return $this->replaceVariables($body, $replaceVars);
}
private function replaceVariables($text, $replaceVars) {
if(!is_array($replaceVars)) return false;
if(!is_array($replaceVars)) return $text;
foreach($replaceVars as $key => $replacement) {
$body = str_replace("{{".$key."}}", $replacement, $body);
$text = str_replace("{{".$key."}}", $replacement, $text);
}
return $text;
}
public function renderBody($body_replacers = null) {
if(is_array($body_replacers)) {
$body = $this->getVariableReplacedBody($body_replacers);
} else {
$body = $this->body_html ? $this->body_html : $this->body_text;
}
// handle EMBED Tokens
$m = [];
if(preg_match_all('/{{EMBED:([^}]+)}}/i', $body, $m)) {
if(array_key_exists(1, $m)) {
foreach($m[1] as $match) {
$tpl_name = $match;
$tpl = MailtemplateModel::getFirst(["code" => $tpl_name]);
if(!$tpl) continue;
$tpl_body = $tpl->body_html ? $tpl->body_html : $tpl->body_text;
$tpl_replace = $this->replaceVariables($tpl_body, $body_replacers);
$body = $this->replaceVariables($body, ["EMBED:$tpl_name" => $tpl_replace]);
}
}
}
return $body;
}
public function renderSubject($subject_replacers = null) {
if(is_array($subject_replacers)) {
$subject = $this->getVariableReplacedSubject($subject_replacers);
} else {
$subject = $this->subject;
}
return $subject;
}
public function getProperty($name) {
if($this->$name == null) {

View File

@@ -53,6 +53,10 @@ class MailtemplateController extends mfBaseController {
private function getPreparedFilter($filter) {
$new_filter = [];
if(array_key_exists("is_include", $filter) && !is_numeric($filter["is_include"])) {
unset($filter["is_include"]);
}
foreach($filter as $name => $value) {
$new_filter[$name] = $value;
}

View File

@@ -608,13 +608,13 @@ class Preorder extends mfBaseModel {
$status = $this->getProperty("status")->getApiArray();
foreach($this->getProperty("statusflags") as $sflag) {
$status["flags"][$sflag->code] = [
$status["flags"][] = [
"code" => (int)$sflag->code,
"text" => $sflag->name,
"value" => ($sflag->value->value == 1)
];
}
//var_dump($status);exit;
$a = [];
$a['code'] = strtoupper($this->ucode);

View File

@@ -13,7 +13,7 @@ final class CreateMailtemplate extends AbstractMigration
$table->addColumn("name", "string", ["null" => false, "limit" => 255]);
$table->addColumn("code", "string", ["null" => false, "limit" => 64]);
$table->addColumn("description", "string", ["null" => true, "default" => null, "limit" => 1024]);
$table->addColumn("subject", "string", ["null" => false, "limit" => 255]);
$table->addColumn("subject", "string", ["null" => true, "default" => null, "limit" => 255]);
$table->addColumn("body_text", "text", ["null" => true, "default" => null]);
$table->addColumn("body_html", "text", ["null" => true, "default" => null]);
$table->addColumn("note", "text", ["null" => true, "default" => null]);

View File

@@ -14,7 +14,7 @@ final class CreateInvoiceJob extends AbstractMigration
$table->addColumn("to_date", "date", ["null" => false]);
$table->addColumn("started", "datetime", ["null" => true, "default" => null]);
$table->addColumn("finished", "datetime", ["null" => true, "default" => null]);
$table->addColumn("status", "string", ["null" => true, "default" => true, "limit" => 64]);
$table->addColumn("status", "string", ["null" => true, "default" => null, "limit" => 64]);
$table->addColumn("result", "json", ["null" => true, "default" => null]);
$table->addColumn("create_by", "integer", ["null" => false]);

View File

@@ -5,7 +5,7 @@ info:
license:
name: Apache 2.0 License
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.2.0
version: 1.2.1
servers:
- url: https://thetool-test.xinon.at/api/v1
- url: https://thetool.xinon.at/api/v1
@@ -545,6 +545,20 @@ paths:
type: string
description: Statustext
example: Fiber installation work assigned
flags:
type: array
items:
type: object
properties:
code:
type: integer
example: 141
text:
type: string
example: "Conduit on property border and FCP prepaired"
value:
type: boolean
example: true
additionalData:
type: object
description: Benutzerdefiniertes Objekt. Wird unverändert gespeichert und in `GET /preorder` wieder ausgegeben
@@ -609,7 +623,7 @@ paths:
description: |
Successful operation
Mögliche Werte für Rückgabewert `status`:
Mögliche `status` Werte:
| code | text | description |
|------|------|-------------|
@@ -618,15 +632,12 @@ paths:
| 120 | Underground construction planning finished | Tiefbau Planung abgeschlossen |
| 130 | Underground construction work assigned | Bauauftrag zugeteilt |
| 140 | Conduit at property border | Rohr an Grundstücksgrenze |
| 145 | Installation kit picked up or shipped | Hausanschlusspaket an Kunden übergeben/versandt |
| 200 | Conduit in building | Rohr im Gebäude |
| 210 | Fiber planning | Leitungsplan in Arbeit |
| 220 | Fiber planning finished | Leitungsplan abgeschlossen |
| 230 | Fiber installation work assigned | Bauauftrag zugeteilt |
| 235 | Fiber on property line | Faser an Grundstücksgrenze |
| 240 | Fiber in building | Faser im Gebäude |
| 241 | BEP installed (multi-dwelling) | HÜP installiert (MPH) |
| 242 | Inhouse cabeling finished (multi-dwelling) | Hausverkabelung erledigt (MPH) |
| 244 | BEP installed (single-dwelling) | HÜP installiert (EFH) |
| 245 | OTO installed | Anschlussbox installiert |
| 250 | ONT ready | ONT vorbereitet |
@@ -638,6 +649,19 @@ paths:
| 910 | Cancelled | Storniert: Keine Begründung |
| 920 | Cancelled | Gekündigt durch Kunde |
| 921 | Cancelled | Gekündigt durch ISP |
---
Mögliche Status `flag`s:
| code | text | description |
|------|------|-------------|
| 141 | Conduit on property border and FCP prepaired | |
| 145 | Installation kit picked up or shipped | Hausanschlusspaket an Kunden übergeben/versandt |
| 150 | Borderpoint connected | |
| 200 | Conduit in building | Rohr im Gebäude |
| 242 | Inhouse cabeling finished (multi-dwelling) | Hausverkabelung erledigt (MPH) |
content:
application/json:
schema:
@@ -684,15 +708,12 @@ paths:
| 120 | Underground construction planning finished | Tiefbau Planung abgeschlossen |
| 130 | Underground construction work assigned | Bauauftrag zugeteilt |
| 140 | Conduit at property border | Rohr an Grundstücksgrenze |
| 145 | Installation kit picked up or shipped | Hausanschlusspaket an Kunden übergeben/versandt |
| 200 | Conduit in building | Rohr im Gebäude |
| 210 | Fiber planning | Leitungsplan in Arbeit |
| 220 | Fiber planning finished | Leitungsplan abgeschlossen |
| 230 | Fiber installation work assigned | Bauauftrag zugeteilt |
| 235 | Fiber on property line | Faser an Grundstücksgrenze |
| 240 | Fiber in building | Faser im Gebäude |
| 241 | BEP installed (multi-dwelling) | HÜP installiert (MPH) |
| 242 | Inhouse cabeling finished (multi-dwelling) | Hausverkabelung erledigt (MPH) |
| 244 | BEP installed (single-dwelling) | HÜP installiert (EFH) |
| 245 | OTO installed | Anschlussbox installiert |
| 250 | ONT ready | ONT vorbereitet |
@@ -704,6 +725,19 @@ paths:
| 910 | Cancelled | Storniert: Keine Begründung |
| 920 | Cancelled | Gekündigt durch Kunde |
| 921 | Cancelled | Gekündigt durch ISP |
---
Mögliche Status `flag`s:
| code | text | description |
|------|------|-------------|
| 141 | Conduit on property border and FCP prepaired | |
| 145 | Installation kit picked up or shipped | Hausanschlusspaket an Kunden übergeben/versandt |
| 150 | Borderpoint connected | |
| 200 | Conduit in building | Rohr im Gebäude |
| 242 | Inhouse cabeling finished (multi-dwelling) | Hausverkabelung erledigt (MPH) |
content:
application/json:
schema:
@@ -1511,6 +1545,21 @@ components:
type: string
description: Statustext
example: Fiber installation work assigned
flags:
type: array
items:
type: object
properties:
code:
type: integer
example: 141
text:
type: string
example: "Conduit on property border and FCP prepaired"
value:
type: boolean
example: true
ciftoken:
type: string
description: Customer Installation Feedback Token
@@ -1629,6 +1678,8 @@ components:
type: string
description: Wert für zusätzliches Feld
example: true
additionalData:
type: object
description: Benutzerdefiniertes Objekt. Wird unverändert gespeichert und in `GET /preorder` wieder ausgegeben
@@ -1662,6 +1713,9 @@ components:
type: object
properties:
ciftoken:
type: string
description: Cif Token
example: AbcdEFG123
code:
type: string
description: Eindeutiger Code der Vorbestellung