Added Contractconfig Edit

This commit is contained in:
Frank Schubert
2022-12-15 20:48:48 +01:00
parent fc67cd133f
commit 9149a0f2cd
16 changed files with 374 additions and 103 deletions

View File

@@ -181,11 +181,13 @@
</td>
<?php endif; ?>
<td>
<a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">
<?=$address->customer_number?>
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
</a>
</td>
<td><?=nl2br($address->company)?></td>
<td><?=$address->getFullName()?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
<td>
<?=$address->street?><br />
<?=$address->zip?> <?=$address->city?>

View File

@@ -29,7 +29,7 @@
<div class="card">
<div class="card-body">
<h4>Person/Firma</h4>
<h3 class="text-center mb-3"><?=$address->getCompanyOrName()?><?=($address->customer_number) ? " [".$address->customer_number."]" : ""?></h3>
<table class="table table-sm table-striped view-table">
<tr>
@@ -129,8 +129,7 @@
<tr>
<th>Typ</th>
<th>Firma</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Name</th>
<th>Telefon</th>
<th>Mobil</th>
<th>Email</th>
@@ -142,8 +141,7 @@
<tr>
<td class="font-weight-bold"><?=__($type)?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->company?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->firstname?></a></td>
<td><?=$link->address->lastname?></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->getFullName()?></a></td>
<td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td>
@@ -168,7 +166,7 @@
<?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?>
<tr>
<td><?=__($type)?> für:</td>
<td><strong><?=__($type)?></strong> für:</td>
<td><a href="<?=self::getUrl("Address", "view", ['id' => $link->origin_address_id])?>"><?=$link->origin->getCompanyOrName()?><?=($link->origin->customer_number) ? " [".$link->origin->customer_number."]" : ""?></a></td>
</tr>
<?php endforeach; ?>
@@ -182,6 +180,49 @@
</div>
</div>
<?php if(is_array($address->contracts) && count($address->contracts)): ?>
<div class="card">
<div class="card-body">
<h4>Verträge</h4>
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
<th>Rolle</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php foreach($address->contracts as $contract): ?>
<tr>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>">
<a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>">
<?php if($contract->owner_id == $address->id): ?>
Vertragsinhaber
<?php elseif($contract->billingaddress_id == $address->id): ?>
Rechnungsempfänger
<?php endif; ?>
</a>
</td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->id?></a></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->product->name?></a></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->order_date) ? date('d.m.Y', $contract->order_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $contract->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Address","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Übersicht</a>

View File

@@ -182,10 +182,9 @@
<th>Matchcode</th>
<th></th>
</tr>
<?php foreach($contract->links as $type => $links): ?>
<?php foreach($links as $link): ?>
<?php foreach($contract->links as $link): ?>
<tr>
<td><?=$type?></td>
<td><?=__($link->type, "contract")?></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $link->contract->owner_id])?>"><?=$link->contract->owner->getCompanyOrName()?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract_id?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?></a></td>
@@ -194,60 +193,10 @@
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
<?php foreach($contract->links as $link): ?>
<div class="form-group row" id="link-<?=$linknum?>">
<label class="col-lg-2 col-form-label" for="links_<?=$link->id?>_contract_id"></label>
<div class="col-lg-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<select class="form-control" name="links[<?=$link->id?>][type]">
<option value="link" <?=($link->type == "link") ? "selected='selected'" : ""?>>Verknüpfung mit</option>
<option value="upgrade" <?=($link->type == "upgrade") ? "selected='selected'" : ""?>>Upgrade von</option>
<option value="downgrade" <?=($link->type == "downgrade") ? "selected='selected'" : ""?>>Downgrade von</option>
<option value="relocation" <?=($link->type == "relocation") ? "selected='selected'" : ""?>>Umzug von</option>
<option value="productchange" <?=($link->type == "productchange") ? "selected='selected'" : ""?>>Produktwechsel von</option>
</select>
</div>
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$link->id?>][contract_id]" id="links_<?=$link->id?>_contract_id" data-linknum="<?=$link->id?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1&preferred_address_id=<?=$contract->owner->id?>" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
<option></option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-danger" onclick="clearNewLink(<?=$link->id?>)"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php $linknum = 1337; ?>
<div class="form-group row" id="link-<?=$linknum?>">
<label class="col-lg-2 col-form-label" for="links_<?=$linknum?>_contract_id"></label>
<div class="col-lg-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<select class="form-control" name="links[<?=$linknum?>][type]">
<option value="link">Verknüpfung mit</option>
<option value="upgrade">Upgrade von</option>
<option value="downgrade">Downgrade von</option>
<option value="relocation">Umzug von</option>
<option value="productchange">Produktwechsel von</option>
</select>
</div>
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
<option></option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-danger" onclick="clearNewLink(<?=$linknum?>)"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -22,14 +22,17 @@
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
<?php if($contract->isCancelled()): ?>
<h2 class="text-center mb-3 text-danger">GEKÜNDIGT</h2>
<?php endif; ?>
<h3 class="text-center mb-3 <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
<table class="table table-sm table-striped view-table">
<tr>
@@ -209,12 +212,15 @@
<div class="card-body">
<h4>Verknüpfte Verträge</h4>
<table class="table table-striped table-sm table-bordered">
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
<th>Kunde</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php foreach($contract->links as $link): ?>
@@ -230,9 +236,12 @@
?>
<tr>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->product->name?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->matchcode?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->product->name?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["id" => $linkcontract->id])?>"><?=$linkcontract->matchcode?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
@@ -272,8 +281,8 @@
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
<a href="<?=self::getUrl("Contract","Index", ['filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['id' => $contract->id, 'filter' => $filter, 's' => $s, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
</div>
</div>

View File

@@ -1,3 +1,106 @@
<?php
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
var_dump($groups);
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
<li class="breadcrumb-item active"><?=$contract->product_name?> [<?=$contract->matchcode?>]</li>
</ol>
</div>
<h4 class="page-title">Aktives Produkt</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
</div>
</div>
<div class="card">
<div class="card-body">
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
<table class="table table-sm table-striped view-table">
<tr>
<th style="max-width: 50vw;">Matchcode:</th>
<td style="width: 50vw;"><?=$contract->matchcode?></td>
</tr>
<tr>
<th>Vertragsinhaber:</th>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</a></td>
</tr>
<tr>
<th>Produkt:</th>
<td><?=$contract->product_name?></td>
</tr><tr>
<th>Produkt Info:</th>
<td><?=$contract->product_info?></td>
</tr>
</table>
</div>
</div>
<div class="card">
<div class="card-body">
<h4 class="text-center mb-3">Konfiguration bearbeiten</h4>
<?php if(is_array($groups) && count($groups)): ?>
<form method="post" action="<?=self::getUrl("Contractconfig", "Save")?>">
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
<table class="table table-sm table-borderless view-table">
<?php foreach($groups as $group): ?>
<tr class="bg-light">
<th><h4><u><?=$group->name?></u></h4></td>
<td></td>
</tr>
<?php foreach($group->items as $item): ?>
<tr>
<th style="max-width: 50vw;"><?=$item->displayname?>:</th>
<td style="width: 50vw;">
<?php if($item->type == "enum"): ?>
<select class="form-control" name="itemvalues[<?=$item->id?>]">
<?php foreach($item->getTypedataArray() as $option): ?>
<option value="<?=$option?>" <?=($item->getValue() == $option) ? "selected='selected'" : ""?>><?=$option?></option>
<?php endforeach; ?>
</select>
<?php else: ?>
<input type="text" class="form-control <?=(is_array($error_items) && in_array($item->id, $error_items)) ? "invalid" : ""?>" name="itemvalues[<?=$item->id?>]" value="<?=(isset($request)) ? $request->itemvalues[$item->id] : $item->getValue()?>" />
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
<div class="row">
<div class="col text-center">
<input type="submit" class="btn btn-primary" value="Konfiguration speichern" />
</div>
</div>
</form>
<?php endif; ?>
</div>
</div>
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
</div>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -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]);

View File

@@ -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] = [];
public function isCancelled() {
if(!$this->id) {
return false;
}
$this->links[$link->type][] = $link;
if(!$this->cancel_date) {
return false;
}
$now = date('U');
if($this->cancel_date < $now) {
return true;
}
if(count($this->links)) {
mfValuecache::singleton()->set("ContractLinks-origin-".$this->id, $this->links);
}
*/
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;
}

View File

@@ -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)) {

View File

@@ -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<br />".implode(", ", $error_items), "warning");
return $this->editAction();
}
$this->layout()->setFlash("Konfiguration gespeichert", "success");
$this->redirect("Contract", "view", ['id' => $contract_id]);
}

View File

@@ -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;
}

View File

@@ -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";

View File

@@ -3,7 +3,7 @@
class ContractconfigItemModel {
public $order;
public $contractconfiggroup_id;
public $ype;
public $type;
public $name;
public $displayname;
public $description;

View File

@@ -1,5 +1,63 @@
<?php
class ContractconfigValue extends mfBaseModel {
private $item;
public function set($new_value) {
$item = $this->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;
}
}

View File

@@ -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) {

View File

@@ -44,4 +44,6 @@ $l['preorder.provision'] = "Vorsorgeanschluss";
$l['preorder.order'] = "Vollanschluss";
$l['preorder.reorder'] = "Nachbestellung";
$l['contract.link'] = "Verknüpfung";
$lang['de'] = $l;

View File

@@ -84,7 +84,7 @@ h1, h2, h3, h4, h5, h6 {
}
.contract-link.canceled {
.canceled {
text-decoration: line-through;
}