diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 3f4724d2d..9be42013f 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -418,11 +418,6 @@ $pagination_entity_name = "Vorbestellungen"; - - diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php index 51f68642b..70926eda6 100644 --- a/Layout/default/Preorder/include/preorder-detail.php +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -102,7 +102,66 @@ - + + + + campaign->network->owner_id === "209"): ?> + + Verrechnet: + +
+ billed) ? 'checked' : ''?> + onchange="updatePreorderBilled(id?>, this.checked)" + /> + +
+ + billed_by): ?> +
Verrechnet durch: billed_by))->name?> am billed)?> Uhr
+ + + + + + Erstellt: create)?> (creator->name?>) diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index d9dab2f30..758ea3e5a 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -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()) + ]; + } + } diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index edd9d6a6e..a32195ed8 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -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']; diff --git a/db/migrations/20250703110000_preorder_add_billing_fields.php b/db/migrations/20250703110000_preorder_add_billing_fields.php new file mode 100644 index 000000000..a5604d2bd --- /dev/null +++ b/db/migrations/20250703110000_preorder_add_billing_fields.php @@ -0,0 +1,35 @@ +getEnvironment() == "thetool") { + $table = $this->table("Preorder"); + $table->addColumn("billed", "integer", ["default" => 0, "after" => "billing_period", "comment" => "UNIX timestamp of when the preorder was billed or 0 if not billed"]); + $table->addColumn("billed_by", "integer", ["default" => 0, "after" => "billing_period", "comment" => "User ID of the user who billed the preorder, 0 if not billed"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $table = $this->table("Preorder"); + $table->removeColumn("billed"); + $table->removeColumn("billed_by"); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}