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
+6 -4
View File
@@ -181,11 +181,13 @@
</td> </td>
<?php endif; ?> <?php endif; ?>
<td> <td>
<?=$address->customer_number?> <a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>">
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?> <?=$address->customer_number?>
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
</a>
</td> </td>
<td><?=nl2br($address->company)?></td> <td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=nl2br($address->company)?></a></td>
<td><?=$address->getFullName()?></td> <td><a href="<?=self::getUrl("Address", "view", ["id" => $address->id, 'filter' => $filter, 's' => $pagination['start']])?>"><?=$address->getFullName()?></a></td>
<td> <td>
<?=$address->street?><br /> <?=$address->street?><br />
<?=$address->zip?> <?=$address->city?> <?=$address->zip?> <?=$address->city?>
+47 -6
View File
@@ -29,7 +29,7 @@
<div class="card"> <div class="card">
<div class="card-body"> <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"> <table class="table table-sm table-striped view-table">
<tr> <tr>
@@ -129,8 +129,7 @@
<tr> <tr>
<th>Typ</th> <th>Typ</th>
<th>Firma</th> <th>Firma</th>
<th>Vorname</th> <th>Name</th>
<th>Nachname</th>
<th>Telefon</th> <th>Telefon</th>
<th>Mobil</th> <th>Mobil</th>
<th>Email</th> <th>Email</th>
@@ -142,8 +141,7 @@
<tr> <tr>
<td class="font-weight-bold"><?=__($type)?></td> <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->company?></a></td>
<td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->firstname?></a></td> <td><a href="<?=self::getUrl("Address", "view", ["id" => $link->address_id])?>"><?=$link->address->getFullName()?></a></td>
<td><?=$link->address->lastname?></td>
<td><?=$link->address->phone?></td> <td><?=$link->address->phone?></td>
<td><?=$link->address->mobile?></td> <td><?=$link->address->mobile?></td>
<td><?=$link->address->email?></td> <td><?=$link->address->email?></td>
@@ -168,7 +166,7 @@
<?php if(array_key_exists($type, $address->linked_as)): ?> <?php if(array_key_exists($type, $address->linked_as)): ?>
<?php foreach($address->linked_as[$type] as $link): ?> <?php foreach($address->linked_as[$type] as $link): ?>
<tr> <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> <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> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@@ -182,6 +180,49 @@
</div> </div>
</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">
<div class="card-body"> <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> <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>
+4 -55
View File
@@ -182,10 +182,9 @@
<th>Matchcode</th> <th>Matchcode</th>
<th></th> <th></th>
</tr> </tr>
<?php foreach($contract->links as $type => $links): ?> <?php foreach($contract->links as $link): ?>
<?php foreach($links as $link): ?>
<tr> <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("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_id?></a></td>
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product->name?></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> <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> </td>
</tr> </tr>
<?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>
</table> </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>
</div> </div>
+18 -9
View File
@@ -22,14 +22,17 @@
<div class="card"> <div class="card">
<div class="card-body"> <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","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-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</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> </div>
<div class="card"> <div class="card">
<div class="card-body"> <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"> <table class="table table-sm table-striped view-table">
<tr> <tr>
@@ -209,12 +212,15 @@
<div class="card-body"> <div class="card-body">
<h4>Verknüpfte Verträge</h4> <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> <tr>
<th>Kunde</th> <th>Kunde</th>
<th>Contract ID</th> <th>Contract ID</th>
<th>Produkt</th> <th>Produkt</th>
<th>Matchcode</th> <th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th> <th></th>
</tr> </tr>
<?php foreach($contract->links as $link): ?> <?php foreach($contract->links as $link): ?>
@@ -230,9 +236,12 @@
?> ?>
<tr> <tr>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td> <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 class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><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 class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><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->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> <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> <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> </td>
@@ -272,8 +281,8 @@
<div class="card"> <div class="card">
<div class="card-body"> <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","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-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</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> </div>
+105 -2
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"); ?>
+11 -2
View File
@@ -4,11 +4,12 @@ class Address extends mfBaseModel {
protected $forcestr = ['street','company','zip','phone','fax','mobile','note']; protected $forcestr = ['street','company','zip','phone','fax','mobile','note'];
private $parent; private $parent;
private $childaddresses; private $childaddresses;
private $links; private $links = [];
private $linked_as; private $linked_as = [];
private $types; private $types;
private $attributes; private $attributes;
private $permissions; private $permissions;
private $contracts;
private $phoneparts; private $phoneparts;
@@ -181,6 +182,14 @@ class Address extends mfBaseModel {
$this->childaddresses = AddressModel::search(['parent' => $this->id]); $this->childaddresses = AddressModel::search(['parent' => $this->id]);
return $this->childaddresses; 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") { if($name == "links_to") {
$links = AddressLinkModel::search(['address_id' => $this->id]); $links = AddressLinkModel::search(['address_id' => $this->id]);
+18 -14
View File
@@ -10,6 +10,7 @@ class Contract extends mfBaseModel {
private $contractConfigGroups; private $contractConfigGroups;
private $contractConfigItems; private $contractConfigItems;
private $configgroups; private $configgroups;
private $isCancelled;
private $links; private $links;
private $linkFrom; private $linkFrom;
private $linkTo; private $linkTo;
@@ -86,22 +87,24 @@ class Contract extends mfBaseModel {
} }
} }
}
/*$this->links = mfValuecache::singleton()->get("ContractLinks-origin-".$this->id);
if(!$this->links) { public function isCancelled() {
$this->links = []; if(!$this->id) {
foreach(ContractLinkModel::search(["origin_contract_id" => $this->id]) as $link) { return false;
if(array_key_exists($link->type, $this->links)) {
$this->links[$link->type] = [];
}
$this->links[$link->type][] = $link;
}
} }
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) { public function getProperty($name) {
@@ -186,6 +189,7 @@ class Contract extends mfBaseModel {
if($name == "links") { if($name == "links") {
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]); $this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
//var_dump($this->links);exit;
return $this->links; return $this->links;
} }
+7
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)) { if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id']; $product_id = $filter['product_id'];
if(is_numeric($product_id)) { if(is_numeric($product_id)) {
@@ -27,13 +27,13 @@ class ContractconfigController extends mfBaseController {
$contract_id = $this->request->contract_id; $contract_id = $this->request->contract_id;
if(!$contract_id) { if(!$contract_id) {
$this->layout()->setFlash("Contract ID nicht gefunden.","danger"); $this->layout()->setFlash("Contract ID nicht gefunden.","error");
$this->redirect("Contract"); $this->redirect("Contract");
} }
$contract = new Contract($contract_id); $contract = new Contract($contract_id);
if(!$contract_id) { if(!$contract_id) {
$this->layout()->setFlash("Contract ID nicht gefunden.","danger"); $this->layout()->setFlash("Contract ID nicht gefunden.","error");
$this->redirect("Contract"); $this->redirect("Contract");
} }
@@ -44,6 +44,51 @@ class ContractconfigController extends mfBaseController {
$this->layout()->set("contract", $contract); $this->layout()->set("contract", $contract);
$this->layout()->set("groups", $contract->configgroups); $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]);
} }
@@ -12,14 +12,52 @@ class ContractconfigItem extends mfBaseModel {
return true; 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) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) {
return null;
}
if($name == "value") { if($name == "value") {
if(!$this->contract_id) { if(!$this->contract_id) {
return null; 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; return $this->value;
} }
@@ -44,7 +44,7 @@ class ContractconfigItemController extends mfBaseController {
break; break;
case "enum": case "enum":
$item_data['type'] = "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; break;
case "int": case "int":
$item_data['type'] = "int"; $item_data['type'] = "int";
@@ -3,7 +3,7 @@
class ContractconfigItemModel { class ContractconfigItemModel {
public $order; public $order;
public $contractconfiggroup_id; public $contractconfiggroup_id;
public $ype; public $type;
public $name; public $name;
public $displayname; public $displayname;
public $description; public $description;
@@ -16,7 +16,7 @@ class ContractconfigItemModel {
public $edit = null; public $edit = null;
public static function create(Array $data) { public static function create(Array $data) {
$model = new ContractconfigItem(); $model = new ContractconfigItem();
foreach($data as $field => $value) { foreach($data as $field => $value) {
@@ -1,5 +1,63 @@
<?php <?php
class ContractconfigValue extends mfBaseModel { 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;
}
} }
@@ -77,9 +77,6 @@ class ProductgroupController extends mfBaseController {
$this->layout()->setFlash("Produktgruppe nicht gefunden", "error"); $this->layout()->setFlash("Produktgruppe nicht gefunden", "error");
$this->redirect("Productgroup"); $this->redirect("Productgroup");
} }
} else {
$mode = "add";
$group = new Productgroup();
} }
$name = trim($r->name); $name = trim($r->name);
@@ -88,7 +85,14 @@ class ProductgroupController extends mfBaseController {
$this->redirect("Productgroup"); $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(); $id = $group->save();
if(!$id) { if(!$id) {
+2
View File
@@ -44,4 +44,6 @@ $l['preorder.provision'] = "Vorsorgeanschluss";
$l['preorder.order'] = "Vollanschluss"; $l['preorder.order'] = "Vollanschluss";
$l['preorder.reorder'] = "Nachbestellung"; $l['preorder.reorder'] = "Nachbestellung";
$l['contract.link'] = "Verknüpfung";
$lang['de'] = $l; $lang['de'] = $l;
+1 -1
View File
@@ -84,7 +84,7 @@ h1, h2, h3, h4, h5, h6 {
} }
.contract-link.canceled { .canceled {
text-decoration: line-through; text-decoration: line-through;
} }