diff --git a/Layout/default/Address/Index.php b/Layout/default/Address/Index.php
index ac44e9cfd..054bc5db5 100644
--- a/Layout/default/Address/Index.php
+++ b/Layout/default/Address/Index.php
@@ -181,11 +181,13 @@
- =$address->customer_number?>
- =($address->spin) ? " ".$address->spin."" : ""?>
+ $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">
+ =$address->customer_number?>
+ =($address->spin) ? " ".$address->spin."" : ""?>
+
|
- =nl2br($address->company)?> |
- =$address->getFullName()?> |
+ $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">=nl2br($address->company)?> |
+ $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">=$address->getFullName()?> |
=$address->street?>
=$address->zip?> =$address->city?>
diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php
index 320917bb2..d8541e2a9 100644
--- a/Layout/default/Address/View.php
+++ b/Layout/default/Address/View.php
@@ -29,7 +29,7 @@
- Person/Firma
+ =$address->getCompanyOrName()?>=($address->customer_number) ? " [".$address->customer_number."]" : ""?>
-
- links as $link): ?>
-
-
-
-
-
+
diff --git a/Layout/default/Contract/View.php b/Layout/default/Contract/View.php
index 9d32719b1..4b67f9c88 100644
--- a/Layout/default/Contract/View.php
+++ b/Layout/default/Contract/View.php
@@ -22,14 +22,17 @@
- =$contract->product_name?> (=$contract->id?>)
+ isCancelled()): ?>
+ GEKÜNDIGT
+
+ ">=$contract->product_name?> (=$contract->id?>)
@@ -209,12 +212,15 @@
Verknüpfte Verträge
-
+
| Kunde |
Contract ID |
Produkt |
Matchcode |
+ Bestelldatum |
+ Fertigstellung |
+ Kündigung |
|
links as $link): ?>
@@ -230,9 +236,12 @@
?>
| $linkcontract->owner_id])?>">=$linkcontract->owner->getCompanyOrName()?> |
- $linkcontract->id])?>">=$linkcontract->id?> |
- $linkcontract->id])?>">=$linkcontract->product->name?> |
- $linkcontract->id])?>">=$linkcontract->matchcode?> |
+ "> $linkcontract->id])?>">=$linkcontract->id?> |
+ "> $linkcontract->id])?>">=$linkcontract->product->name?> |
+ "> $linkcontract->id])?>">=$linkcontract->matchcode?> |
+ ">=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?> |
+ ">=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?> |
+ ">=($linkcontract->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">
|
@@ -272,8 +281,8 @@
diff --git a/Layout/default/Contractconfig/Form.php b/Layout/default/Contractconfig/Form.php
index 9157fa834..bfa7d3f5f 100644
--- a/Layout/default/Contractconfig/Form.php
+++ b/Layout/default/Contractconfig/Form.php
@@ -1,3 +1,106 @@
-
-var_dump($groups);
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+ =$contract->product_name?> (=$contract->id?>)
+
+
+
+
+
+
+
+
+
+ Konfiguration bearbeiten
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/Address/Address.php b/application/Address/Address.php
index 29340a0a7..889de6ae3 100644
--- a/application/Address/Address.php
+++ b/application/Address/Address.php
@@ -4,11 +4,12 @@ class Address extends mfBaseModel {
protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
private $parent;
private $childaddresses;
- private $links;
- private $linked_as;
+ private $links = [];
+ private $linked_as = [];
private $types;
private $attributes;
private $permissions;
+ private $contracts;
private $phoneparts;
@@ -181,6 +182,14 @@ class Address extends mfBaseModel {
$this->childaddresses = AddressModel::search(['parent' => $this->id]);
return $this->childaddresses;
}
+
+ if($name == "contracts") {
+ $owning = ContractModel::search(['owner_id' => $this->id]);
+ $billing = ContractModel::search(['billingaddress_id' => $this->id]);
+ $this->contracts = array_merge($owning, $billing);
+ return $this->contracts;
+ }
+
/*
if($name == "links_to") {
$links = AddressLinkModel::search(['address_id' => $this->id]);
diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php
index 33a61cbed..fc2dfd6d6 100644
--- a/application/Contract/Contract.php
+++ b/application/Contract/Contract.php
@@ -10,6 +10,7 @@ class Contract extends mfBaseModel {
private $contractConfigGroups;
private $contractConfigItems;
private $configgroups;
+ private $isCancelled;
private $links;
private $linkFrom;
private $linkTo;
@@ -86,22 +87,24 @@ class Contract extends mfBaseModel {
}
}
-
-
- /*$this->links = mfValuecache::singleton()->get("ContractLinks-origin-".$this->id);
- if(!$this->links) {
- $this->links = [];
- foreach(ContractLinkModel::search(["origin_contract_id" => $this->id]) as $link) {
- if(array_key_exists($link->type, $this->links)) {
- $this->links[$link->type] = [];
- }
- $this->links[$link->type][] = $link;
- }
+ }
+
+
+ public function isCancelled() {
+ if(!$this->id) {
+ return false;
}
- if(count($this->links)) {
- mfValuecache::singleton()->set("ContractLinks-origin-".$this->id, $this->links);
+
+ if(!$this->cancel_date) {
+ return false;
}
- */
+
+ $now = date('U');
+ if($this->cancel_date < $now) {
+ return true;
+ }
+
+ return false;
}
public function getProperty($name) {
@@ -186,6 +189,7 @@ class Contract extends mfBaseModel {
if($name == "links") {
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
+ //var_dump($this->links);exit;
return $this->links;
}
diff --git a/application/Contract/ContractModel.php b/application/Contract/ContractModel.php
index f9b99337c..9d97cb5d3 100644
--- a/application/Contract/ContractModel.php
+++ b/application/Contract/ContractModel.php
@@ -172,6 +172,13 @@ class ContractModel {
}
}
+ if(array_key_exists("billingaddress_id", $filter)) {
+ $billingaddress_id = $filter['billingaddress_id'];
+ if(is_numeric($billingaddress_id)) {
+ $where .= " AND Contract.billingaddress_id=$billingaddress_id";
+ }
+ }
+
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
diff --git a/application/Contractconfig/ContractconfigController.php b/application/Contractconfig/ContractconfigController.php
index 32a88ce49..be688787c 100644
--- a/application/Contractconfig/ContractconfigController.php
+++ b/application/Contractconfig/ContractconfigController.php
@@ -27,13 +27,13 @@ class ContractconfigController extends mfBaseController {
$contract_id = $this->request->contract_id;
if(!$contract_id) {
- $this->layout()->setFlash("Contract ID nicht gefunden.","danger");
+ $this->layout()->setFlash("Contract ID nicht gefunden.","error");
$this->redirect("Contract");
}
$contract = new Contract($contract_id);
if(!$contract_id) {
- $this->layout()->setFlash("Contract ID nicht gefunden.","danger");
+ $this->layout()->setFlash("Contract ID nicht gefunden.","error");
$this->redirect("Contract");
}
@@ -44,6 +44,51 @@ class ContractconfigController extends mfBaseController {
$this->layout()->set("contract", $contract);
$this->layout()->set("groups", $contract->configgroups);
+ }
+
+ protected function saveAction() {
+ $r = $this->request;
+ $contract_id = $r->contract_id;
+
+ if(!is_numeric($contract_id) || $contract_id < 1) {
+ $this->layout()->setFlash("Contract ID nicht gefunden.","error");
+ $this->redirect("Contract");
+ }
+
+ if(!is_array($r->itemvalues) || !count($r->itemvalues)) {
+ $this->layout()->setFlash("Keine Änderungen.","info");
+ $this->redirect("Contract");
+ }
+
+ $error_items = [];
+
+ foreach($r->itemvalues as $item_id => $itemvalue) {
+ $item = new ContractconfigItem($item_id);
+ if(!$item->id) {
+ $this->log->warn("Tried to save non-existant ContractconfigItem $item_id");
+ continue;
+ }
+ $item->setContractId($contract_id);
+ if(!$item->value->set($itemvalue)) {
+ $error_items[$item->id] = $item->name;
+ continue;
+ }
+ if(!$item->value->save()) {
+ $this->layout()->set("request", $r);
+ $this->layout()->setFlash("Fehler beim Speichern von".$item->name,"info");
+ return $this->editAction();
+ }
+ }
+
+ if(count($error_items)) {
+ $this->layout()->set("error_items", array_keys($error_items));
+ $this->layout()->set("request", $r);
+ $this->layout()->setFlash("Konfiguration nicht vollständig gespeichert. Fehler in folgenden Feldern:\n ".implode(", ", $error_items), "warning");
+ return $this->editAction();
+ }
+
+ $this->layout()->setFlash("Konfiguration gespeichert", "success");
+ $this->redirect("Contract", "view", ['id' => $contract_id]);
}
diff --git a/application/ContractconfigItem/ContractconfigItem.php b/application/ContractconfigItem/ContractconfigItem.php
index 71dc66e83..cae0ef27c 100644
--- a/application/ContractconfigItem/ContractconfigItem.php
+++ b/application/ContractconfigItem/ContractconfigItem.php
@@ -12,14 +12,52 @@ class ContractconfigItem extends mfBaseModel {
return true;
}
+ public function getValue() {
+ $value = $this->getProperty("value");
+ if(!$value) {
+ return null;
+ }
+
+ if($this->type == "int") {
+ return $value->int;
+ }
+ if($this->type == "decimal") {
+ return $value->number;
+ }
+
+ return $value->string;
+ }
+
+ public function getTypedataArray() {
+ if(!$this->typedata) {
+ return [];
+ }
+
+ return explode("\n", $this->typedata);
+ }
+
public function getProperty($name) {
if($this->$name == null) {
+ if(!$this->id) {
+ return null;
+ }
+
if($name == "value") {
if(!$this->contract_id) {
return null;
}
- $this->value = ContractconfigValueModel::getFirst(['item_id' => $this->id, "contract_id" => $this->contract_id]);
+ $value = ContractconfigValueModel::getFirst(['item_id' => $this->id, "contract_id" => $this->contract_id]);
+ if(!$value) {
+ $me = new User();
+ $me->loadMe();
+ $value = new ContractconfigValue();
+ $value->item_id = $this->id;
+ $value->contract_id = $this->contract_id;
+ $value->create_by = $me->id;
+ }
+
+ $this->value = $value;
return $this->value;
}
diff --git a/application/ContractconfigItem/ContractconfigItemController.php b/application/ContractconfigItem/ContractconfigItemController.php
index 53ffa13a3..2c14c0420 100644
--- a/application/ContractconfigItem/ContractconfigItemController.php
+++ b/application/ContractconfigItem/ContractconfigItemController.php
@@ -44,7 +44,7 @@ class ContractconfigItemController extends mfBaseController {
break;
case "enum":
$item_data['type'] = "enum";
- $item_data['typedata'] = $r->data;
+ $item_data['typedata'] = preg_replace(['/\n{2,}/','/^\n+/','/\n+$/'], ["\n",'',''], str_replace("\r","\n",$r->data));
break;
case "int":
$item_data['type'] = "int";
diff --git a/application/ContractconfigItem/ContractconfigItemModel.php b/application/ContractconfigItem/ContractconfigItemModel.php
index 3a0ce4e85..045ad96c5 100644
--- a/application/ContractconfigItem/ContractconfigItemModel.php
+++ b/application/ContractconfigItem/ContractconfigItemModel.php
@@ -3,7 +3,7 @@
class ContractconfigItemModel {
public $order;
public $contractconfiggroup_id;
- public $ype;
+ public $type;
public $name;
public $displayname;
public $description;
@@ -16,7 +16,7 @@ class ContractconfigItemModel {
public $edit = null;
- public static function create(Array $data) {
+ public static function create(Array $data) {
$model = new ContractconfigItem();
foreach($data as $field => $value) {
diff --git a/application/ContractconfigValue/ContractconfigValue.php b/application/ContractconfigValue/ContractconfigValue.php
index c59f79872..b6615a63d 100644
--- a/application/ContractconfigValue/ContractconfigValue.php
+++ b/application/ContractconfigValue/ContractconfigValue.php
@@ -1,5 +1,63 @@
getProperty("item");
+
+ if($new_value === null || strlen($new_value) == 0) {
+ $this->int = null;
+ $this->number = null;
+ $this->string = null;
+ return true;
+ }
+
+ if($item->type == "int") {
+ if(!is_numeric($new_value)) return false;
+ $this->int = $new_value;
+ } elseif($item->type == "decimal") {
+ if(!is_float($new_value) && !is_numeric($new_value)) return false;
+ $this->number = $new_value;
+ } elseif(is_scalar($new_value)) {
+ $this->string = $new_value;
+ } else {
+ return false;
+ }
+
+ $me = new User();
+ $me->loadMe();
+ $this->edit_by = $me->id;
+
+ return true;
+ }
+
+ public function getProperty($name) {
+ if($this->$name == null) {
+
+ if(!$this->id) {
+ return null;
+ }
+
+ if($name == "item") {
+ $this->item = new ContractconfigItem($this->item_id);
+ if(!$this->item->id) {
+ return null;
+ }
+ return $this->item;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = new $classname($this->$idfield);
+
+ if($this->$name->id) {
+ return $this->$name;
+ } else {
+ return null;
+ }
+ }
+
+ return $this->$name;
+ }
}
\ No newline at end of file
diff --git a/application/Productgroup/ProductgroupController.php b/application/Productgroup/ProductgroupController.php
index d8b1cd5da..38a5cc812 100644
--- a/application/Productgroup/ProductgroupController.php
+++ b/application/Productgroup/ProductgroupController.php
@@ -77,9 +77,6 @@ class ProductgroupController extends mfBaseController {
$this->layout()->setFlash("Produktgruppe nicht gefunden", "error");
$this->redirect("Productgroup");
}
- } else {
- $mode = "add";
- $group = new Productgroup();
}
$name = trim($r->name);
@@ -88,7 +85,14 @@ class ProductgroupController extends mfBaseController {
$this->redirect("Productgroup");
}
- $group->name = $r->name;
+ $group_data = [];
+ $group_data['name'] = $name;
+
+ if($mode == "edit") {
+ $group->update($group_data);
+ } else {
+ $group = ProductgroupModel::create(['name' => $name]);
+ }
$id = $group->save();
if(!$id) {
diff --git a/lang/de.php b/lang/de.php
index 87cdf1d1f..fca251ea6 100644
--- a/lang/de.php
+++ b/lang/de.php
@@ -44,4 +44,6 @@ $l['preorder.provision'] = "Vorsorgeanschluss";
$l['preorder.order'] = "Vollanschluss";
$l['preorder.reorder'] = "Nachbestellung";
+$l['contract.link'] = "Verknüpfung";
+
$lang['de'] = $l;
\ No newline at end of file
diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css
index 811fbaab4..7c12de288 100644
--- a/public/assets/css/thetool.css
+++ b/public/assets/css/thetool.css
@@ -84,7 +84,7 @@ h1, h2, h3, h4, h5, h6 {
}
-.contract-link.canceled {
+.canceled {
text-decoration: line-through;
}
|