Added Preorder cancel request UI changes

This commit is contained in:
Frank Schubert
2025-09-17 12:15:52 +02:00
parent f6edba49a0
commit bad591e80d
4 changed files with 188 additions and 13 deletions

View File

@@ -6,6 +6,9 @@
<div class="col-12">
<ul class="nav nav-tabs order-tab">
<li class="nav-item"><a class="nav-link active" href="#preorder-detail-<?=$preorder->id?>-detail" data-toggle="tab" aria-expanded="false">Bestellung</a></li>
<?php if($preorder->cancel_request): ?>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-cancelation" data-toggle="tab" aria-expanded="false">Storno/Kündigung</a></li>
<?php endif; ?>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-address" data-toggle="tab" aria-expanded="false">Adressdetails</a></li>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-flags" data-toggle="tab" aria-expanded="false">Status</a></li>
<?php if($preorder->campaign->fulfillment != "citycom_oan"): ?>
@@ -293,6 +296,47 @@
</div>
</div>
<?php if($preorder->cancel_request): ?>
<div id="preorder-detail-<?=$preorder->id?>-cancelation" class="tab-pane">
<div class="row justify-content-center">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="card-header bg-info text-white pl-2 pr-2 pt-1 pb-1">Storno/Kündigung</div>
<div class="row">
<div class="col-6">
<h3>Storno / Kündigung</h3>
<table class="table table-sm table-striped">
<tr>
<th>Kündigungsdatum</th>
<td class="text-monospace"><?=($preorder->cancel_request_execution_date) ? (new DateTime($preorder->cancel_request_execution_date))->format("d.m.Y") : ""?></td>
</tr><tr>
<th>Demontage ab</th>
<td class="text-monospace"><?=($preorder->cancel_request_execution_date) ? (new DateTime($preorder->cancel_request_execution_date))->modify("+1 day")->format("d.m.Y") : ""?></td>
</tr><tr>
<th>Kündigungsgrund</th>
<td class="text-monospace"><?=$preorder->cancel_request_status->code?> - <?=$preorder->cancel_request_status->name?></td>
</tr><tr>
<th>Kündigung erstellt</th>
<td class="text-monospace"><?=date("d.m.Y H:i", $preorder->cancel_request)?> (<?=$preorder->cancel_request_creator->name?>)</td>
</tr>
</table>
<button type="button" class="btn btn-success" onclick="approveCancelRequest(<?=$preorder->id?>)"><i class="fas fa-check"></i> Kündigung freigeben</button>
<button type="button" class="btn btn-danger ml-2" onclick="denyCancelRequest(<?=$preorder->id?>)"><i class="fas fa-xmark"></i> Kündigung ablehnen</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div id="preorder-detail-<?=$preorder->id?>-address" class="tab-pane">
<div class="row justify-content-center">
<div class="col-12">

View File

@@ -24,6 +24,8 @@ class Preorder extends mfBaseModel {
private $citycomoan; // ONT data
private $ctags; // network-keyed array of Ctags
private $statusjournals;
private $cancel_request_status;
private $cancel_request_creator;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
@@ -1573,19 +1575,6 @@ class Preorder extends mfBaseModel {
}
if($name == "creator") {
$user = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if($user) {
$this->creator = $user;
return $this->creator;
}
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
return $this->creator;
}
if($name === 'fcp') {
if(!$this->adb_hausnummer->fcp_id) return null;
return ADBRimoFcp::get($this->adb_hausnummer->fcp_id);
@@ -1605,8 +1594,69 @@ class Preorder extends mfBaseModel {
return $this->ctags;
}
if($name == "cancel_request_status") {
if(!$this->cancel_request_status_code) return null;
$this->cancel_request_status = mfValuecache::singleton()->get("mfObjectmodel-Preorderstatus-code-" . $this->cancel_request_status_code);
if(!$this->cancel_request_status) {
$cancel_request_status = PreorderstatusModel::getFirst(["code" => $this->cancel_request_status_code]);
if($cancel_request_status) {
mfValuecache::singleton()->set("mfObjectmodel-Preorderstatus-code-" . $this->cancel_request_status_code, $cancel_request_status);
$this->cancel_request_status = $cancel_request_status;
}
}
return $this->cancel_request_status;
}
if($name == "cancel_request_creator") {
$user = mfValuecache::singleton()->get("Worker-id-" . $this->cancel_request_by);
if($user) {
$this->cancel_request_creator = $user;
return $this->cancel_request_creator;
}
$this->cancel_request_creator = new User($this->cancel_request_by);
if($this->cancel_request_creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->cancel_request_by, $this->cancel_request_creator);
}
return $this->cancel_request_creator;
}
if($name == "cancel_approver") {
$user = mfValuecache::singleton()->get("Worker-id-" . $this->cancel_approved_by);
if($user) {
$this->cancel_approver = $user;
return $this->cancel_approver;
}
$this->cancel_approver = new User($this->cancel_approved_by);
if($this->cancel_approver->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->cancel_approved_by, $this->cancel_approver);
}
return $this->editor;
}
if($name == "creator") {
$user = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if($user) {
$this->creator = $user;
return $this->creator;
}
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
return $this->creator;
}
if($name == "editor") {
$user = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
if($user) {
$this->editor = $user;
return $this->editor;
}
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
}
return $this->editor;
}

View File

@@ -1090,6 +1090,12 @@ class PreorderController extends mfBaseController {
case "saveStatusJournal":
$return = $this->saveStatusJournalApi();
break;
case "approveCancelRequest":
$return = $this->approveCancelRequest();
break;
case "denyCancelRequest":
$return = $this->denyCancelRequest();
break;
default:
$return = false;
}
@@ -1108,6 +1114,49 @@ class PreorderController extends mfBaseController {
}
}
protected function approveCancelRequest() {
return true; // disabled
$preorder_id = $this->request->pid;
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
$this->log->debug(__METHOD__.": Preorder $preorder_id not found");
return false;
}
if(!$preorder->cancel_request) {
$this->log->debug(__METHOD__.": Preorder $preorder_id has no cancel request");
return false;
}
}
protected function denyCancelRequest() {
return true; // disabled
$preorder_id = $this->request->pid;
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
$this->log->debug(__METHOD__.": Preorder $preorder_id not found");
return false;
}
if(!$preorder->cancel_request) {
$this->log->debug(__METHOD__.": Preorder $preorder_id has no cancel request");
return false;
}
// empty all cancel request fields
$preorder->cancel_request = null;
$preorder->cancel_request_by = null;
$preorder->cancel_request_status_code = null;
$preorder->cancel_request_execution_date = null;
$preorder->save();
return ["message" => "Cancel request removed"];
}
protected function saveStatusJournalApi() {
$preorder_id = $this->request->preorder_id;
$text = $this->request->text;

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class PreorderAddCancelRequestStatusCode extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("Preorder");
$table->addColumn("cancel_request_status_code", "string", ["null" => true, "default" => null, "limit" => 64, "after" => "cancel_request_by"]);
$table->addColumn("cancel_request_execution_date", "date", ["null" => true, "default" => null, "limit" => 64, "after" => "cancel_request_status_code"]);
$table->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("Preorder")->removeColumn("cancel_request_status_code")->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
}