added filter for sended emails

This commit is contained in:
Luca Haid
2025-07-03 12:00:36 +02:00
parent 4bec93b14e
commit 72858d3eb3
5 changed files with 133 additions and 6 deletions

View File

@@ -1080,6 +1080,9 @@ class PreorderController extends mfBaseController {
case "setBilled":
$return = $this->setBilledApi();
break;
case "updateBilled":
$return = $this->updateBilledApi();
break;
default:
$return = false;
}
@@ -1610,4 +1613,29 @@ class PreorderController extends mfBaseController {
return ["message" => "Workorder deleted successfully", "id" => $preorder->id, "wid" => $wo_id];
}
private function updateBilledApi() {
$preorder_id = $this->request->id;
if (!is_numeric($preorder_id) || $preorder_id < 1) return false;
$preorder = new Preorder($preorder_id);
if (!$preorder->id) return false;
$billed = $this->request->billed ? (string)time() : "0";
$preorder->billed = $billed;
$preorder->billed_by = $this->me->id;
if (!$preorder->save()) return false;
return [
"message" => "Billed status updated successfully",
"id" => $preorder_id,
"billed" => $billed,
"billed_by_name" => $this->me->name,
"billed_by_id" => $this->me->id,
"billed_date" => date("d.m.Y H:i", $preorder->billed ? $preorder->billed : time())
];
}
}

View File

@@ -1076,6 +1076,13 @@ class PreorderModel
}
}
if (array_key_exists("onlyShowCustomMailSent", $filter)) {
// Only apply the filter if the value is truthy (e.g., true, 1)
if ($filter['onlyShowCustomMailSent']) {
$where .= " AND tt_preorder.id IN (SELECT preorder_id FROM PreorderStatusnotificationLog WHERE email_type = '300-custom')";
}
}
// custom where clause
if (array_key_exists("add-where", $filter)) {
$where .= " " . $filter['add-where'];