More Contract stuff
This commit is contained in:
@@ -172,6 +172,58 @@
|
||||
<div class="card">
|
||||
<div class="card-body" id="link-container">
|
||||
<h4>Verknüpfungen</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered">
|
||||
<tr>
|
||||
<th>Verknüpfung</th>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $type => $links): ?>
|
||||
<?php foreach($links as $link): ?>
|
||||
<tr>
|
||||
<td><?=$type?></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>
|
||||
<td><a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->matchcode?></a></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>
|
||||
</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>
|
||||
|
||||
@@ -32,7 +32,12 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_owner">Inhaber</label>
|
||||
<label class="form-label" for="filter_owner">Kundennummer</label>
|
||||
<input type="text" class="form-control" name="filter[customer_number]" id="filter_street" value="<?=$filter['customer_number']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_owner">Inhaber Name</label>
|
||||
<input type="text" class="form-control" name="filter[owner]" id="filter_street" value="<?=$filter['owner']?>" />
|
||||
</div>
|
||||
|
||||
@@ -51,6 +56,13 @@
|
||||
<input type="text" class="form-control" name="filter[product_name]" id="filter_product_name" value="<?=$filter['product_name']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_show_canceled">Gekündigte Produkte</label>
|
||||
<select class="form-control" name="filter[show_canceled]" id="filter_show_canceled">
|
||||
<option value="0" <?=($filter['show_canceled'] == 0) ? "selected='selected'" : ""?>>Ausblenden</option>
|
||||
<option value="1" <?=($filter['show_canceled'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
<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")?>">Verträge</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"><?=$contract->product_name?> [<?=$contract->matchcode?>] (<?=$contract->id?>)</h4>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,87 +29,119 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Vertragsinhaber</h4>
|
||||
<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;">ID:</th>
|
||||
<td style="width: 50vw;"><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->id?></a></td>
|
||||
</tr><tr>
|
||||
<th>Kundennummer:</th>
|
||||
<td><?=$contract->owner->customer_number?></td>
|
||||
</tr><tr>
|
||||
<th>Adresse:</th>
|
||||
<td>
|
||||
<?=($contract->owner->company) ? nl2br($contract->owner->company)."<br />" : ""?>
|
||||
<?=$contract->owner->firstname?> <?=$contract->owner->lastname?><br />
|
||||
<?=$contract->owner->street?><br />
|
||||
<?=$contract->owner->zip?> <?=$contract->owner->city?>
|
||||
<?=($contract->owner->country) ? "<br />".$contract->owner->country : "" ?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kontakt:</th>
|
||||
<td>
|
||||
<?=($contract->owner->phone) ? "Telefon: ".$contract->owner->phone."<br />" : ""?>
|
||||
<?=($contract->owner->mobile) ? "Mobil: ".$contract->owner->mobile."<br />" : ""?>
|
||||
<?=($contract->owner->fax) ? "Fax: ".$contract->owner->fax."<br />" : ""?>
|
||||
<?=($contract->owner->email) ? "Email: ".$contract->owner->email."<br />" : ""?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
</tr><tr>
|
||||
<th>Service PIN:</th>
|
||||
<td><?=$contract->owner->spin?></td>
|
||||
</tr><tr>
|
||||
<th>Einwilligungen:</th>
|
||||
<td>
|
||||
<p><i class="mr-1 fas <?=($contract->owner->allow_contact) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i> Informationen per Post/Email/Telefon</p>
|
||||
<p><i class="mr-1 fas <?=($contract->owner->allow_spin) ? "fa-check text-success" : "fa-xmark-large text-danger"?>"></i>Auskunft mit Service PIN</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if($contract->billingaddress_id): ?>
|
||||
<tr>
|
||||
<td colspan="2" class="bg-white"><h4>Rechungsempfänger</h4></td>
|
||||
</tr><tr>
|
||||
<th>ID:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->billingaddress->id])?>"><?=$contract->billingaddress->id?></a></td>
|
||||
</tr><tr>
|
||||
<th>Kundennummer:</th>
|
||||
<td><?=$contract->billingaddress->customer_number?></td>
|
||||
</tr><tr>
|
||||
<th>Adresse:</th>
|
||||
<td>
|
||||
<?=($contract->billingaddress->company) ? nl2br($contract->billingaddress->company)."<br />" : ""?>
|
||||
<?php if($contract->billingaddress->firstname || $contract->billingaddress->lastname): ?><?=$contract->billingaddress->firstname?> <?=$contract->billingaddress->lastname?><br /><?php endif; ?>
|
||||
<?=$contract->billingaddress->street?><br />
|
||||
<?=$contract->billingaddress->zip?> <?=$contract->billingaddress->city?>
|
||||
<?=($contract->billingaddress->country) ? "<br />".$contract->billingaddress->country : "" ?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Kontakt:</th>
|
||||
<td>
|
||||
<?=($contract->billingaddress->phone) ? "Telefon: ".$contract->billingaddress->phone."<br />" : ""?>
|
||||
<?=($contract->billingaddress->mobile) ? "Mobil: ".$contract->billingaddress->mobile."<br />" : ""?>
|
||||
<?=($contract->billingaddress->fax) ? "Fax: ".$contract->billingaddress->fax."<br />" : ""?>
|
||||
<?=($contract->billingaddress->email) ? "Email: ".$contract->billingaddress->email."<br />" : ""?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
|
||||
<h4>Vertrag</h4>
|
||||
<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>
|
||||
</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>
|
||||
<?php if($contract->billingaddress_id): ?>
|
||||
<tr>
|
||||
<th>Rechnungsempfänger:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->billingaddress->getCompanyOrName()?> (<?=$contract->billingaddress->customer_number?>)</a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr><tr>
|
||||
</tr>
|
||||
<!-- upgrades -->
|
||||
<?php if(is_array($contract->upgradeFrom) && count($contract->upgradeFrom)): ?>
|
||||
<tr>
|
||||
<th>Upgrade von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->upgradeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->upgradeTo) && count($contract->upgradeTo)): ?>
|
||||
<tr>
|
||||
<th>Upgrade auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->upgradeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- downgrades -->
|
||||
<?php if(is_array($contract->downgradeFrom) && count($contract->downgradeFrom)): ?>
|
||||
<tr>
|
||||
<th>Downgrade von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->downgradeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->downgradeTo) && count($contract->downgradeTo)): ?>
|
||||
<tr>
|
||||
<th>Downgrade auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->downgradeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- productchange -->
|
||||
<?php if(is_array($contract->productchangeFrom) && count($contract->productchangeFrom)): ?>
|
||||
<tr>
|
||||
<th>Produktwechsel von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->productchangeFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->productchangeTo) && count($contract->productchangeTo)): ?>
|
||||
<tr>
|
||||
<th>Produktwechsel auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->productchangeTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- relocation -->
|
||||
<?php if(is_array($contract->relocationFrom) && count($contract->relocationFrom)): ?>
|
||||
<tr>
|
||||
<th>Umzug von:</th>
|
||||
<td>
|
||||
<?php foreach($contract->relocationFrom as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->origin_contract_id])?>" class="contract-link <?=($link->origin->cancel_date && $link->origin->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->origin->product_name?> [<?=$link->origin->matchcode?>] (<?=$link->origin_contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if(is_array($contract->relocationTo) && count($contract->relocationTo)): ?>
|
||||
<tr>
|
||||
<th>Umzug auf:</th>
|
||||
<td>
|
||||
<?php foreach($contract->relocationTo as $link): ?>
|
||||
<a href="<?=self::getUrl("Contract", "View", ["id" => $link->contract_id])?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr>
|
||||
<th>SLA:</th>
|
||||
<td><?=$contract->sla->name?></td>
|
||||
</tr><tr>
|
||||
@@ -157,14 +189,60 @@
|
||||
<th>Erstellt:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->create)?> (<?=$contract->creator->name?>)</td>
|
||||
</tr><tr>
|
||||
<th>Zuletzte bearbeitet:</th>
|
||||
<th>Zuletzt bearbeitet:</th>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i:s',$contract->edit)?> (<?=$contract->editor->name?>)</td>
|
||||
</tr><tr class="bg-white">
|
||||
<td colspan="2" class="text-center">
|
||||
<a href="<?=self::getUrl("Contractconfig", "edit", ["contract_id" => $contract->id])?>"><button type="button" class="btn btn-sm btn-outline-info">Konfiguration bearbeiten</button></a>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">Inhaberwechsel</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-success">Produkt-/Standortwechsel</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger">Kündigen</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Verknüpfte Verträge</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered">
|
||||
<tr>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$linkcontract = $link->origin;
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<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>
|
||||
<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; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<!--
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Konfiguration</h4>
|
||||
@@ -190,7 +268,7 @@
|
||||
<a href="#" class="btn btn-sm btn-outline-primary">Konfiguration bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
3
Layout/default/Contractconfig/Form.php
Normal file
3
Layout/default/Contractconfig/Form.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
var_dump($groups);
|
||||
247
Layout/default/Contractconfiggroup/Index.php
Normal file
247
Layout/default/Contractconfiggroup/Index.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
$siteTitle = "Benutzer";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- 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")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contractconfig")?>">Contractconfig</a></li>
|
||||
<li class="breadcrumb-item">Contractconfig</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Contractconfig</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="row">
|
||||
<div class="col-lg">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<form method="post" action="<?=self::getUrl("Contractconfiggroup", "save")?>">
|
||||
<label class="form-label" for="">Neue Config Gruppe anlegen</label>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" name="name" placeholder="Gruppenname..." />
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-plus"></i> Gruppe hinzufügen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($configgroups) && count($configgroups)): ?>
|
||||
<?php foreach($configgroups as $group): ?>
|
||||
<h4>Gruppe <?=$group->name?> <small><a href="#" onclick="$('#item-form-<?=$group->id?>').toggle()"><i class="fas fa-plus"></i> Neues Element erstellen</a></small></h4>
|
||||
|
||||
<div class="card hidden" id="item-form-<?=$group->id?>">
|
||||
<div class="card-body">
|
||||
<form method="post" action="<?=self::getUrl("ContractconfigItem", "save")?>">
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row col">
|
||||
<h5>Neues Config Element</h5>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_new_name" name="name" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_type">Datentyp</label>
|
||||
<select class="form-control" id="item_new_type" name="type" onchange='toggleTypedata("new")'>
|
||||
<option value="string">String</option>
|
||||
<option value="int">Ganzzahl</option>
|
||||
<option value="decimal">Dezimalzahl</option>
|
||||
<option value="enum">Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_new">
|
||||
<div class="enum hidden">
|
||||
<label for="item_new_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_new_data" name="data"></textarea>
|
||||
</div>
|
||||
<div class="pattern">
|
||||
<label for="item_new_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_new_pattern" name="pattern" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_new_displayname" name="displayname" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_new_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_new_description" name="description" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($group->items) && count($group->items)): ?>
|
||||
<?php $i = 0; foreach($group->items as $item): ?>
|
||||
|
||||
<div class="list-group">
|
||||
<a href="#" class="list-group-item list-group-item-action" onclick="$('#item-edit-<?=$item->id?>').toggle()"><span class="text-monospace text-pink"><?=$item->name?></span> - <?=$item->displayname?> [<?=$item->type?>]</a>
|
||||
|
||||
|
||||
<div class="card hidden" id="item-edit-<?=$item->id?>">
|
||||
<div class="card-body">
|
||||
|
||||
<form method="post" action="<?=self::getUrl("ContractconfigItem", "save")?>">
|
||||
<input type="hidden" name="item_id" value="<?=$item->id?>" />
|
||||
<input type="hidden" name="group_id" value="<?=$group->id?>" />
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_name">Name <small class="text-monospace">[a-z0-9._-]</small></label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_name" name="name" value="<?=$item->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_type">Datentyp</label>
|
||||
<select class="form-control" id="item_<?=$item->id?>_type" name="type" onchange="toggleTypedata(<?=$item->id?>)">
|
||||
<option value="string" <?=($item->type == "string") ? "selected='selected'" : ""?>>String</option>
|
||||
<option value="int" <?=($item->type == "int") ? "selected='selected'" : ""?>>Ganzzahl</option>
|
||||
<option value="decimal" <?=($item->type == "decimal") ? "selected='selected'" : ""?>>Dezimalzahl</option>
|
||||
<option value="enum" <?=($item->type == "enum") ? "selected='selected'" : ""?>>Auswahl</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group" id="typedata_<?=$item->id?>">
|
||||
<div class="enum <?=($item->type != "enum") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_data">Auswahldaten (1 Element pro Zeile)</label>
|
||||
<textarea class="form-control" style="height: 128px" id="item_<?=$item->id?>_data" name="data"><?=$item->typedata?></textarea>
|
||||
</div>
|
||||
<div class="pattern <?=($item->type != "string") ? "hidden" : ""?>">
|
||||
<label for="item_<?=$item->id?>_pattern">Regex Pattern</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_pattern" name="pattern" value="<?=$item->pattern?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_displayname">Anzeigename</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_displayname" name="displayname" value="<?=$item->displayname?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="item_<?=$item->id?>_description">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="item_<?=$item->id?>_description" name="description" value="<?=$item->description?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-11 float-left">
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</div>
|
||||
<div class="col-md-1 float-right">
|
||||
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "deleteItem", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php else: ?>
|
||||
<i>Keine Configgruppen gefunden</i>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#address_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
|
||||
var item;
|
||||
var hash = window.location.hash.substr(1);
|
||||
var match = hash.match(/item=(\d+)/);
|
||||
if(match && match[1]) {
|
||||
item = match[1]
|
||||
$('#item-edit-' + item).show()
|
||||
var pos = $('#item-edit-' + item).offset().top;
|
||||
$(window).scrollTop(pos);
|
||||
}
|
||||
|
||||
function toggleTypedata(id) {
|
||||
var type = $('#item_' + id + '_type').val();
|
||||
if(type == "enum") {
|
||||
$('#typedata_' + id + " .enum").show();
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
} else if(type == "string") {
|
||||
$('#typedata_' + id + " .pattern").show();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
} else {
|
||||
$('#typedata_' + id + " .pattern").hide();
|
||||
$('#typedata_' + id + " .enum").hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?><?php
|
||||
@@ -41,7 +41,7 @@
|
||||
<label class="col-lg-2 col-form-label" for="contractconfiggroups">Contractconfig Groups</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control select2-multiple" name="contractconfiggroups[]" id="contractconfiggroups" multiple="multiple" data-placeholder="Choose ...">
|
||||
<?php foreach(ContractconfigGroupModel::getAll() as $ccgroup): ?>
|
||||
<?php foreach(ContractconfiggroupModel::getAll() as $ccgroup): ?>
|
||||
<option value="<?=$ccgroup->id?>" <?=(is_array($group->contractconfiggroups) && array_key_exists($ccgroup->id, $group->contractconfiggroups)) ? "selected='selected'" : ""?>><?=$ccgroup->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<ul class="submenu">
|
||||
<li><a href="<?=self::getUrl("Contract")?>"><i class="fas fa-file-contract"></i> Verträge</a></li>
|
||||
<li><hr /></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfig")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
<li><a href="<?=self::getUrl("Contractconfiggroup")?>"><i class="fas fa-wrench"></i> Vertragsconfig</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -10,12 +10,100 @@ class Contract extends mfBaseModel {
|
||||
private $contractConfigGroups;
|
||||
private $contractConfigItems;
|
||||
private $configgroups;
|
||||
private $links;
|
||||
private $linkFrom;
|
||||
private $linkTo;
|
||||
private $upgradeFrom;
|
||||
private $upgradeTo;
|
||||
private $downgradeFrom;
|
||||
private $downgradeTo;
|
||||
private $productchangeFrom;
|
||||
private $productchangeTo;
|
||||
private $relocationFrom;
|
||||
private $relocationTo;
|
||||
private $finisher;
|
||||
private $canceler;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
private function getLinks() {
|
||||
$this->linkFrom = [];
|
||||
$this->linkTo = [];
|
||||
$this->upgradeFrom = [];
|
||||
$this->upgradeTo = [];
|
||||
$this->downgradeFrom = [];
|
||||
$this->downgradeTo = [];
|
||||
$this->productchangeFrom = [];
|
||||
$this->productchangeTo = [];
|
||||
$this->relocationFrom = [];
|
||||
$this->relocationTo = [];
|
||||
|
||||
// Links targeting this contract (to)
|
||||
foreach(ContractLinkModel::search(['origin_contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeTo[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeTo[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeTo[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationTo[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ContractLinkModel::search(['contract_id' => $this->id]) as $link) {
|
||||
switch($link->type) {
|
||||
case "link":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeFrom[] = $link;
|
||||
break;
|
||||
case "downgrade":
|
||||
$this->downgradeFrom[] = $link;
|
||||
break;
|
||||
case "productchange":
|
||||
$this->productchangeFrom[] = $link;
|
||||
break;
|
||||
case "relocation":
|
||||
$this->relocationFrom[] = $link;
|
||||
break;
|
||||
default:
|
||||
$this->log->warn("ContractLink with invalid type: ".$link->id." ".$link->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*$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;
|
||||
}
|
||||
}
|
||||
if(count($this->links)) {
|
||||
mfValuecache::singleton()->set("ContractLinks-origin-".$this->id, $this->links);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -96,6 +184,18 @@ class Contract extends mfBaseModel {
|
||||
return $this->contractConfigItems;
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
if(in_array($name, ['linkFrom','linkTo','upgradeFrom','upgradeTo','downgradeFrom','downgradeTo','productchangeFrom','productchangeTo','relocationFrom','relocationTo'])) {
|
||||
if($this->$name === null) {
|
||||
$this->getLinks();
|
||||
}
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if($name == "finisher") {
|
||||
$this->finisher = mfValuecache::singleton()->get("Worker-id-".$this->finish_date_by);
|
||||
if($this->finisher === null) {
|
||||
|
||||
@@ -47,6 +47,14 @@ class ContractController extends mfBaseController {
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(array_key_exists("show_canceled", $filter)) {
|
||||
if($filter['show_canceled'] == 0) {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
} else {
|
||||
$new_filter['add-where'] = " AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())";
|
||||
}
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
@@ -198,7 +206,8 @@ class ContractController extends mfBaseController {
|
||||
$this->layout()->setFlash("Vertrag erfolgreich gespeichert.", "success");
|
||||
|
||||
|
||||
|
||||
/* ContractLinks */
|
||||
|
||||
|
||||
$query = [];
|
||||
if($r->s) {
|
||||
|
||||
@@ -201,6 +201,13 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("customer_number", $filter)) {
|
||||
$customer_number = $filter['customer_number'];
|
||||
if(is_numeric($customer_number)) {
|
||||
$where .= " AND Address.customer_number=$customer_number";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner", $filter)) {
|
||||
$owner = FronkDB::singleton()->escape($filter["owner"]);
|
||||
if($owner) {
|
||||
@@ -208,6 +215,10 @@ class ContractModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
69
application/ContractLink/ContractLink.php
Normal file
69
application/ContractLink/ContractLink.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class ContractLink extends mfBaseModel {
|
||||
private $contract;
|
||||
private $origin;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if(!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($name == "origin") {
|
||||
$this->origin = mfValuecache::singleton()->get("mfObjectmodel-Contract-".$this->origin_contract_id);
|
||||
if($this->origin === null) {
|
||||
$this->origin = new Contract($this->origin_contract_id);
|
||||
if($this->origin->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Contract-".$this->id, $this->origin);
|
||||
}
|
||||
}
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
$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") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
|
||||
if($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
170
application/ContractLink/ContractLinkModel.php
Normal file
170
application/ContractLink/ContractLinkModel.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
class ContractLinkModel {
|
||||
public $contract_id;
|
||||
public $origin_contract_id;
|
||||
public $type;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractLink();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractLink", "*", "1 = 1 ORDER BY contract_id,origin_contract_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractLink($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function includesContractId($contract_id, $filter=[]) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE (contract_id=$contract_id OR origin_contract_id=$contract_id)
|
||||
AND $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) FROM ContractLink
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ContractLink
|
||||
WHERE $where
|
||||
ORDER BY contract_id,origin_contract_id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
//var_dump($filter);exit;
|
||||
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
$where .= " AND ContractLink.contract_id = '$contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("origin_contract_id", $filter)) {
|
||||
$origin_contract_id = $filter['origin_contract_id'];
|
||||
if(is_numeric($origin_contract_id)) {
|
||||
$where .= " AND ContractLink.origin_contract_id = '$origin_contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,100 +15,37 @@ class ContractconfigController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfigGroupModel::search([]);
|
||||
|
||||
$this->layout()->set("configgroups", $groups);
|
||||
}
|
||||
|
||||
protected function viewAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$this->layout()->setTemplate("Contractconfig/Form");
|
||||
|
||||
$contract_id = $this->request->contract_id;
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","danger");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($contract_id);
|
||||
if(!$contract_id) {
|
||||
$this->layout()->setFlash("Contract ID nicht gefunden.","danger");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
if(!is_array($contract->configgroups) || !count($contract->configgroups)) {
|
||||
$this->layout()->setFlash("Produkt hat keine Vertragsconfiggruppen hinterlegt.","info");
|
||||
$this->redirect("Contract", "View", ["id" => $contract_id]);
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
$this->layout()->set("groups", $contract->configgroups);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function addGroupAction() {
|
||||
$groupname = ucfirst(trim($this->request->name));
|
||||
|
||||
if(!$groupname) {
|
||||
$this->layout()->setFlash("Gruppenname darf nicht leer sein!", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$group = ContractconfigGroupModel::getFirst(["name" => $groupname]);
|
||||
if($group) {
|
||||
$this->layout()->setFlash("Gruppe gibs scho", "warn");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$group = ContractconfigGroupModel::create(["name" => $groupname]);
|
||||
$group_id = $group->save();
|
||||
if(!$group_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Gruppe $groupname erfolgreich angelegt", "success");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$item_id = $r->item_id;
|
||||
if(is_numeric($item_id) && $item_id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->layout()->setFlash("Element nicht gefunden", "error");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->group_id;
|
||||
$item_data['name'] = $r->name;
|
||||
$item_data['displayname'] = $r->displayname;
|
||||
$item_data['description'] = $r->description;
|
||||
|
||||
$item_data['typedata'] = "";
|
||||
$item_data['pattern'] = "";
|
||||
|
||||
switch($r->type) {
|
||||
case "string":
|
||||
$item_data['type'] = "string";
|
||||
$item_data['pattern'] = $r->pattern;
|
||||
break;
|
||||
case "enum":
|
||||
$item_data['type'] = "enum";
|
||||
$item_data['typedata'] = $r->data;
|
||||
break;
|
||||
case "int":
|
||||
$item_data['type'] = "int";
|
||||
break;
|
||||
case "decimal":
|
||||
$item_data['type'] = "decimal";
|
||||
break;
|
||||
default:
|
||||
$this->layout()->setFlash("Ungültiger Datentyp!");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$item->update($item_data);
|
||||
} else {
|
||||
$item = ContractconfigItemModel::create($item_data);
|
||||
}
|
||||
|
||||
//var_dump($item);exit;
|
||||
|
||||
$item_id = $item->save();
|
||||
|
||||
if(!$item_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern!");
|
||||
$this->redirect("Contractconfig");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Element erfolgreich gespeichert", "success");
|
||||
$this->redirect("Contractconfig");
|
||||
//$this->redirect("Contractconfig","Index","","item=$item_id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigItemController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$item_id = $r->item_id;
|
||||
if(is_numeric($item_id) && $item_id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ContractconfigItem($item_id);
|
||||
if(!$item->id) {
|
||||
$this->layout()->setFlash("Element nicht gefunden", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$item_data['contractconfiggroup_id'] = $r->group_id;
|
||||
$item_data['name'] = $r->name;
|
||||
$item_data['displayname'] = $r->displayname;
|
||||
$item_data['description'] = $r->description;
|
||||
|
||||
$item_data['typedata'] = "";
|
||||
$item_data['pattern'] = "";
|
||||
|
||||
switch($r->type) {
|
||||
case "string":
|
||||
$item_data['type'] = "string";
|
||||
$item_data['pattern'] = $r->pattern;
|
||||
break;
|
||||
case "enum":
|
||||
$item_data['type'] = "enum";
|
||||
$item_data['typedata'] = $r->data;
|
||||
break;
|
||||
case "int":
|
||||
$item_data['type'] = "int";
|
||||
break;
|
||||
case "decimal":
|
||||
$item_data['type'] = "decimal";
|
||||
break;
|
||||
default:
|
||||
$this->layout()->setFlash("Ungültiger Datentyp!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
if($mode == "edit") {
|
||||
$item->update($item_data);
|
||||
} else {
|
||||
$item = ContractconfigItemModel::create($item_data);
|
||||
}
|
||||
|
||||
//var_dump($item);exit;
|
||||
|
||||
$item_id = $item->save();
|
||||
|
||||
if(!$item_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern!");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Element erfolgreich gespeichert", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
//$this->redirect("Contractconfig","Index","","item=$item_id");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroup extends mfBaseModel {
|
||||
class Contractconfiggroup extends mfBaseModel {
|
||||
private $items;
|
||||
private $contract_id;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class ContractconfiggroupController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$groups = ContractconfiggroupModel::search([]);
|
||||
|
||||
$this->layout()->set("configgroups", $groups);
|
||||
}
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$groupname = ucfirst(trim($this->request->name));
|
||||
|
||||
if(!$groupname) {
|
||||
$this->layout()->setFlash("Gruppenname darf nicht leer sein!", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::getFirst(["name" => $groupname]);
|
||||
if($group) {
|
||||
$this->layout()->setFlash("Gruppe gibs scho", "warn");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$group = ContractconfiggroupModel::create(["name" => $groupname]);
|
||||
$group_id = $group->save();
|
||||
if(!$group_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Gruppe $groupname erfolgreich angelegt", "success");
|
||||
$this->redirect("Contractconfiggroup");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigGroupModel {
|
||||
class ContractconfiggroupModel {
|
||||
public $name;
|
||||
|
||||
public $create_by = null;
|
||||
@@ -10,7 +10,7 @@ class ContractconfigGroupModel {
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ContractconfigGroup();
|
||||
$model = new Contractconfiggroup();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
@@ -36,10 +36,10 @@ class ContractconfigGroupModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ContractconfigGroup", "*", "1=1 ORDER BY name, `create`");
|
||||
$res = $db->select("Contractconfiggroup", "*", "1=1 ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -50,10 +50,10 @@ class ContractconfigGroupModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigGroup", "*", "$where ORDER BY name, `create` LIMIT 1");
|
||||
$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create` LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigGroup($data);
|
||||
$item = new Contractconfiggroup($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
@@ -68,19 +68,19 @@ class ContractconfigGroupModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ContractconfigGroup.* FROM ContractconfigGroup
|
||||
LEFT JOIN ContractconfiggroupProductgroup ON (ContractconfigGroup.id = ContractconfiggroupProductgroup.contractconfiggroup_id)
|
||||
$sql = "SELECT Contractconfiggroup.* FROM Contractconfiggroup
|
||||
LEFT JOIN ContractconfiggroupProductgroup ON (Contractconfiggroup.id = ContractconfiggroupProductgroup.contractconfiggroup_id)
|
||||
LEFT JOIN Productgroup ON (ContractconfiggroupProductgroup.productgroup_id = Productgroup.id)
|
||||
WHERE $where
|
||||
GROUP BY ContractconfigGroup.id
|
||||
ORDER BY ContractconfigGroup.name, ContractconfigGroup.`create`
|
||||
GROUP BY Contractconfiggroup.id
|
||||
ORDER BY Contractconfiggroup.name, Contractconfiggroup.`create`
|
||||
";
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
//$res = $db->select("ContractconfigGroup", "*", "$where ORDER BY name, `create`");
|
||||
//$res = $db->select("Contractconfiggroup", "*", "$where ORDER BY name, `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigGroup($data);
|
||||
$items[] = new Contractconfiggroup($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -93,7 +93,7 @@ class ContractconfigGroupModel {
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND ContractconfigGroup.name='$name'";
|
||||
$where .= " AND Contractconfiggroup.name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class ContractconfiggroupProductgroup extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "contractconfiggroup") {
|
||||
$this->contractconfiggroup = new ContractconfigGroup($this->contractconfiggroup_id);
|
||||
$this->contractconfiggroup = new Contractconfiggroup($this->contractconfiggroup_id);
|
||||
return $this->contractconfiggroup;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,14 @@ h1, h2, h3, h4, h5, h6 {
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
.contract-link {
|
||||
|
||||
}
|
||||
|
||||
.contract-link.canceled {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
|
||||
/**************************
|
||||
* custom styles
|
||||
|
||||
Reference in New Issue
Block a user