diff --git a/Layout/default/Contract/CancelForm.php b/Layout/default/Contract/CancelForm.php new file mode 100644 index 000000000..f0275976c --- /dev/null +++ b/Layout/default/Contract/CancelForm.php @@ -0,0 +1,193 @@ + + + +
+
+
+ +

Aktives Produkt

+
+
+
+ + +
+
+ + + +
+
+

product_name?> (id?>)

+ + + + + + + + + + + + + + + + + + + + + +
Matchcode:matchcode?>
Vertragsinhaber: $contract->owner->id])?>">owner->getCompanyOrName()?> (owner->customer_number?>)
Produkt:product_name?> [product_id?>]product_name != $contract->product->name) ? " (".$contract->product->name.")" : ""?>
Produkt Info:product_info?>
Fertigstellungsdatum:finish_date)?>
+ +
+
+ + +
+
+

Kündigung

+ +
"> + + +
+
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+
+ +
+
+
+
+ +
+
+ + linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?> +

Verknüpfte Verträge

+ + + + + + + + + + + + + + + links as $link): ?> + contract_id == $contract->id) { + $linkcontract = $link->origin; + } else { + $linkcontract = $link->contract; + + } + + ?> + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+
+ +
+
+
+ + +
+
+ + + + + +
+
+ + + + + \ No newline at end of file diff --git a/Layout/default/Contract/ProductchangeForm.php b/Layout/default/Contract/ProductchangeForm.php index 4ec20f25f..7a1a67b1f 100644 --- a/Layout/default/Contract/ProductchangeForm.php +++ b/Layout/default/Contract/ProductchangeForm.php @@ -9,7 +9,7 @@ - +

Aktives Produkt

diff --git a/Layout/default/Contract/View.php b/Layout/default/Contract/View.php index 47aae99e7..0783d4064 100644 --- a/Layout/default/Contract/View.php +++ b/Layout/default/Contract/View.php @@ -411,7 +411,7 @@ isFinished()) ? "not-finished" : "" ?> price_setup < 0) ? "text-danger" : ""?>">€ price_setup,4,",",".")?> isFinished()) ? "not-finished" : "" ?>">order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?> isFinished()) ? "not-finished" : "" ?>">finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?> - isFinished()) ? "not-finished" : "" ?>">cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?> + isFinished()) ? "not-finished" : "" ?> cancel_date) ? "text-danger font-weight-bold" : ""?>">cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?> $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"> diff --git a/application/Admin/functions/IvtCreditImport.php b/application/Admin/functions/IvtCreditImport.php index e6835690b..f2079af4d 100644 --- a/application/Admin/functions/IvtCreditImport.php +++ b/application/Admin/functions/IvtCreditImport.php @@ -272,7 +272,7 @@ class Admin_IvtCreditImport { $link = ContractLinkModel::create([ 'contract_id' => $cred_contract->id, 'origin_contract_id' => $contract->id, - 'type' => 'link' + 'type' => 'credit' ]); $link->save(); } diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php index 1c4274eb2..9b791b0c2 100644 --- a/application/Contract/ContractController.php +++ b/application/Contract/ContractController.php @@ -115,6 +115,82 @@ class ContractController extends mfBaseController } + protected function cancelAction() { + $this->layout()->setTemplate("Contract/CancelForm"); + + $id = $this->request->contract_id; + if (!$id) $id = $this->request->id; + + if(!$id) { + $id = $this->request->id; + } + if (!is_numeric($id) || !$id) { + $this->layout()->setFlash("Vertrag nicht gefunden", "error"); + $this->redirect("Contract"); + } + + $contract = new Contract($id); + if (!$contract->id) { + $this->layout()->setFlash("Vertrag nicht gefunden", "error"); + $this->redirect("Contract"); + } + + $this->layout()->set("contract", $contract); + + } + + protected function saveCancel() { + $r = $this->request; + + $id = $r->contract_id; + if (!is_numeric($id) || !$id) { + $this->layout()->setFlash("Vertrag nicht gefunden", "error"); + $this->redirect("Contract"); + } + + $contract = new Contract($id); + if (!$contract->id) { + $this->layout()->setFlash("Vertrag nicht gefunden", "error"); + $this->redirect("Contract"); + } + + try { + $cancel_date = DateTime::createFromFormat("d.m.Y", trim($r->cancel_date), new DateTimeZone("Europe/Vienna")); + $cancel_date->setTime(2,0,0); + } catch(Exception $e) { + $this->layout()->setFlash("Ungültiges Datumsformat"); + $this->redirect("Contract", "cancel", ["contract_id" => $contract->id]); + } + + $contract->cancel_date = $cancel_date->getTimestamp(); + if(!$contract->save()) { + $this->layout()->setFlash("Verlinkten Vertrag $link_id nicht gefunden", "error"); + $this->redirect("Contract", "cancel", ["contract_id" => $contract->id]); + } + + if(is_array($r->links)) { + foreach($r->links as $link_id => $action) { + if($action == "cancel") { + $link_contract = new Contract($link_id); + + if (!$link_contract->id) { + $this->layout()->setFlash("Verlinkten Vertrag $link_id nicht gefunden", "warning"); + continue; + } + + $link_contract->cancel_date = $cancel_date->getTimestamp(); + if(!$link_contract->save()) { + $this->layout()->setFlash("Fehler beim Speichern von verlinktem Vertrag", "warning"); + } + } + } + } + + $this->layout()->setFlash("Kündigung gespeichert", "success"); + $this->redirect("Contract", "view", ["contract_id" => $contract->id]); + + } + protected function productchangeAction() { $this->layout()->setTemplate("Contract/ProductchangeForm"); @@ -387,18 +463,6 @@ class ContractController extends mfBaseController } - protected function cancelAction() - { - $id = $this->request->contract_id; - if (!$id) $id = $this->request->id; - - $this->layout()->setFlash("Not implemented", "error"); - if ($id) { - $this->redirect("Contract", "view", ["id" => $id]); - } else { - $this->redirect("Contract"); - } - } protected function addAction() { diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index a70e9d160..51429528d 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -93,6 +93,10 @@ h1, h2, h3, h4, h5, h6 { color: #323a36; } +.text-dark-red { + color: #c1554c !important; +} + .card { border: 1px solid #ced4da; /*box-shadow: 3px 3px 2px #a0a0a0;*/